1 List<List<Test>> testList = new List<List<Test>>(); 2 3 List<Test> singleTest=new List<Test> (); 5 Test test1= new Test(); 6 test1.Name = "test"; 7 Test test2 = new Test();
8 singleTest.Add(test1); 9 singleTest.Add(test2);
10 List<Test> singleTest1 = new List<Test>(); 11 Test test3 = new Test(); 12 test3.Name = "test1"; 13 Test test4 = new Test();
14 singleTest1.Add(test3); 15 singleTest1.Add(test4); 16 17 18 testList.Add(singleTest); 19 testList.Add(singleTest1);
需求:linq 从testList中取Name为test那条数据
testList.SelectMany(x => x.AsEnumerable()).Where(x => x.Name == "test").ToList();