Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq Select Subset of master list

Tags:

c#

linq

I have a master list of complex objects.

I have a list of int ids that I need to select the corresponding complex object out of the master list.

this doesn't work

MasterListofComplexObj.Where(u => MasterListofComplexObj.Select(i => i.Id).Contains(ChildListofIntIds));

any help would be appreciated.

like image 735
jim Avatar asked Jan 30 '12 19:01

jim


1 Answers

This should work:

var results = MasterListofComplexObj.Where(u => ChildListofIntIds.Contains(u.Id));
like image 178
BrokenGlass Avatar answered Oct 04 '22 08:10

BrokenGlass