There are 2 large list of objects, where I need to do a where clause and find the matching records.
List<A> a= ...;
List<A> b = ...;
A model
Id
Name
Age
Address
I need to return a list that contains all the object of List after comparing with List.
The properties I should check is : If the Ids
are equal, if the Names
are equal and if the ages
are equal.
List<A> common = a.Where(n => b.Select(o => o.Id).Contains(n.Id))
.Where(n => b.Select(o => o.Name).Contains(n.Name))
.Where(n => b.Select(o => o.Age).Contains(n.Age))
There should be something wrong with this, as it returns a Null
.