我有以下课程:
public class Animal
{
}
public class Merge
{
public Animal First { get; set; }
public IEnumerable<Animal> All { get; set; }
}
[如果我通过Linq获得List<Merge>
是可能的,则获取List<Animal>
的列表,其中包含每个Merge
对象(第一和全部)的所有动物预先谢谢你
IEnumerable<Merge> merges = new List<Merge>();
var animals = merges.SelectMany(m => m.All).ToList();
public class Animal
{
//some codes...
}
public class Merge
{
public Merge()
{
AnimalFirst=new Animal();
}
public AnimalFirst { get; set; }
public IEnumerable<Animal> All { get; set; }
}
List<Merge> merges = new List<Merge>();
var animals = merges.AnimalFirst ;
var All =merges.All;