I have 2 lists of 2 different objects:
public class A {
string Id;
string Name;
List<B> listofB;
}
public class B {
string Id;
string Test;
}
The Id in B
is the same as the Id in A
now I have 2 lists
var listA = new List<A>();
var listB = new List<B>();
How would you add every B
object where the Id's match to the list of A
via linq?
for now I did:
foreach(var a in listA){
a.listofB = listB.FindAll(i => i.Id == a.Id);
}
But I would think there is a better way of doing this
(This always returns null for now, still trying to figure out why)