var results = from thing in AnArrayOfThings
let list = Function(thing)
???
select OneLongResultsList;
如何合并所有"列表"收藏成一个长长的清单? 我是linq的新手,我不能使用lambda表达式。
基本上,我想做的是:
List<Result> results = new ...;
foreach (Thing t in ListOfThings)
{
List<Result> list = Function( t );
results.MergeOrAdd( list );
}
答案 0 :(得分:2)
也许你只需要SelectMany
?
var results = AnArrayOfThings.SelectMany(x => Function(x));
或者在查询语法中:
var results = from thing in AnArrayOfThings
from thingInAList in Function(thing)
select thingInAList;