Linq - 我如何将这些合并为一个IQueryable?

时间:2012-09-19 17:56:26

标签: c# .net linq iqueryable

我有一个简单的(混淆的)类:

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>>。如何将所有这些列表整合到一个包罗万象的集合中?

1 个答案:

答案 0 :(得分:5)

尝试使用以下内容:

things.SelectMany(t => t.Strings);
相关问题