Sort a list and all its nested objects using LINQ

前端 未结 5 2054
情书的邮戳
情书的邮戳 2021-01-04 23:49

There is an organisation with several departments and each department has a few employees.

I have created the following object model:

public class O         


        
5条回答
  •  悲哀的现实
    2021-01-05 00:06

    var legalEntitiesCollectionByType = new Dictionary>
                {
                    {
                        "Institutional", organisations
                            .Where(x => x.Type == "Institutional")
                            .ToList()
                            .Select(o => new Organisation{Code = x.Code,Departaments = x.Departaments.OrderBy(c => c).ToList()  }).ToList()
                    }
                }
    

提交回复
热议问题