Flatten a list which one of its properties is another list of object

前端 未结 3 478
南笙
南笙 2021-01-19 19:26

I have the following classes:

public class Owner
{
    public string Id { get; set; }
    public string Name { get; set; }
}
public class Main
{
    public s         


        
3条回答
  •  无人共我
    2021-01-19 20:19

    List
    mainList = ... var flatList = ( from main in mainList from owner in main.Owners select new FlatList { Id = main.Id, Name = main.Name, OwnerId = owner.Id, OwnerName = owner.Name }).ToList();

提交回复
热议问题