Is a lambda expression from this possible?

2019-04-10 17:16发布

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;

?

标签: c# linq lambda
1条回答
Fickle 薄情
2楼-- · 2019-04-10 17:36

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)

查看更多
登录 后发表回答