2
Answers

Inner joining to list using Linq

David Smith

David Smith

13y
1.8k
1
I am try to inner join to list, I am struggline , can someone assist me.



                                                   var groupList = from List1 in List1.AsEnumerable()
                                                                         join List2 in List2.AsEnumerable()
                                                                         on new
                                                                         {
                                                                             KEY1 = List1.ConcatString,
                                                                             KEY2 = List1.CreationWriteTime
                                                                         }
                                                                         equals new
                                                                         {
                                                                             KEY1 = List2.ConcatString,
                                                                             KEY2 = List2.CreationWriteTime
                                                                         }
                                                                         select List2;

Answers (2)
0
David Smith

David Smith

NA 2k 0 13y
yea i just made up a quick example to get the point across.
0
Vulpes

Vulpes

NA 96k 2.6m 13y
Apart from the fact that your iteration variables List1 and List2 should be named differently to the collections they're iterating over, it looks OK to me.

You can certainly compare anonymous types for equality if they have the same structure which yours do have, so there shouldn't be a problem there.