List<Object> 使用Linq

 List<Asset> bdList = allAsset.Where(m => m.Owner.Depts == view.DeptName).ToList();
                    var query = from item in bdList
                                group item by new
                                {
                                    mainName = item.MainCategory.Name,
                                    subName = item.SubCategory.Name,
                                    assetName = item.Name,
                                    stateName = item.State.Name
                                }
                                    into gp
                                    select new
                                    {
                                        MainCategory = gp.First().MainCategory.Name,
                                        SubCategory = gp.First().SubCategory.Name,
                                        AssetName = gp.First().Name,
                                        StateName = gp.First().State.Name,
                                        CostTotal = gp.Sum(m => m.Cost)
                                    };
原文地址:https://www.cnblogs.com/lishidefengchen/p/5681941.html