我有一个简单的(混淆的)类:
public Thing ()
{
public IList<string> Strings()
{
// returns an IList of whatever,
// using strings as an example
}
}
在我的代码的其他地方,我检索到 IQueryable<Thing> things
来自数据库
我的目标是获得所有 string
来自things
合二为一IQueryable<string> strings
,也许是这样的:
var strings = from t in things
select t.Strings()
但这只能给我一个IQueryable<IList<string>>
。如何将所有这些列表合并到一个包罗万象的集合中?
最佳答案
尝试使用类似的东西:
things.SelectMany(t => t.Strings);
关于c# - Linq - 如何将它们合并成一个 IQueryable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12500280/