Exactly how LINQ’s “where” method is defined? I’m guessing implementation is something like this:
public static IEnumerable<T> Where ( this partialParent, Func<bla,bla> myDelegate )
Now if I invoke Where method like this:
from c in context.Con
where ( c.Col1 == c.Col2 )
select c
I’m guessing "c.Col1 == c.Col2" is passed down and some foreach loop does the checking. But what is going on when I invoke where like this:
where ( c.Col1 == c.Col2 || c.Col3 == c.Col4 )
Does the two “checks” are passed down as a whole expression? Maybe I’m missing something very simple.
The query syntax you mention for
wherebasically creates a method and delegate, and calls the method syntax version with it. Whatever you callwherewith is turned into a single method and then called via a delegate on each element of the source sequence.So possibly what you mean by the two checks being passed as a whole expression; that’s what is happening…
it turned into a single method call like this:
and is then called on each element. (obviously the above is pseudo-code)