selectMany在功能LINQ中

时间:2012-06-18 15:43:04

标签: c# .net linq

var collecion = new List<List<ToTest>>
                    {
                        new List<ToTest>{new ToTest {Id = 1, Name = "some name"}, new ToTest {Id = 4, Name = "some name2"}},
                        new List<ToTest>{new ToTest {Id = 2, Name = "some name"}, new ToTest {Id = 5, Name = "some name2"}},
                        new List<ToTest>{new ToTest {Id = 3, Name = "some name"}, new ToTest {Id = 6, Name = "some name2"}},
                    };

我想使用功能性linq而不是lambda linq

    var result1 = collecion.SelectMany(q => q).ToList();

1 个答案:

答案 0 :(得分:9)

var result1 = from collection in collections
              from item in collection
              select item;