views:

68

answers:

1

I have an array of strings and an IQueryable (called MyTypeQbl).

I want to iterate through the strings in the array which do not have a corresponding MyType.MyString.

I thought this would be:

foreach (string str in stringsArr.Where(s => MyTypeQbl.Count(m => m.MyString == s) == 0))

But is this just more complex than it should be? Is there an easier way to represent this?

The mental loop I'm stuck in is that I'm trying to find strings in a string array which do not match a property inside objects in an IQueryable!

+3  A: 
foreach (string str in
    stringsArr.Where(s => !MyTypeQbl.Any(m => m.MyString == s)))
LukeH
You should state why this is better: In the original form, the entire collection is scanned to count the number of matches. In you revised form, the scan is aborted once a match is found.
James Curran