пятница, 15 июля 2011 г.

LINQ: Select where object does not contain items from list


dump this into a more specific collection of just the ids you don't want
var notTheseBarIds = filterBars.Select(fb => fb.BarId);
then try this:
fooSelect = (from f in fooBunch
             where !notTheseBarIds.Contains(f.BarId)
             select f).ToList();
or this:
fooSelect = fooBunch.Where(f => !notTheseBarIds.Contains(f.BarId)).ToList();

1 комментарий:

Анонимный комментирует...

Thanks much!
That saved my time!