Tutorial :Is a lambda expression from this possible?



Question:

I know

from f in list   where f.bar == someVar  select f   

can be written as

list.Where( f => f.bar == someVar );  

Can a similar expression be created from

from f in foo  from b in f.bar  where b.something == someVar  select b;  

?


Solution:1

from maps (for subsequent terms) to SelectMany:

var query = foo.SelectMany(f=>f.bar).Where(b=>b.something==someVar);  

(note that no final Select is necessary for trivial projections)


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »