Thursday, March 24, 2011

Linq to SQl query extensions

query = query.Where(m => m.People.Contains(s)).Select(m => m).ToList();

In the above, "People" is an IList of strings. IF I replace People with a list of objects with string as a field of that object, how do I get the same results.

From stackoverflow
  • How about:

    query = query.Where(m => m.People.Any(p => p.SomeProp == s)).ToList();
    
    Mehrdad Afshari : +1 You beat me to it

0 comments:

Post a Comment