我有这个LINQ to Entiy:
var grouppedClientFullReview = (from cfr in clientFullReview
group cfr by new { cfr.clientId, cfr.clientName } into g
select new
{
siteNumbers = g.Select(x => x.siteId).Count(),
clientId = g.Key.clientId,
clientName = g.Key.clientName,
WorkPlanReview = new
{
frequency = g.Select(x => x.inspectionFrequency),
isNormal = g.Any(x => x.isNormal == false) ? false : true,
objectsID = g.Select(x => x.objectID).ToArray(),
}
}).ToList();
我需要在WorkPlanReview属性中实现group by。
我的问题是如何在WorkPlanReview中实现组? 嵌套组是否可行?
答案 0 :(得分:0)
如果您想按WorkPlanReview
属性本身进行分组,则可以通过以下方式结束查询:
}).GroupBy(g => g.WorkPlanReview).ToList();
如果您想对其中一个WorkPlanReview
属性进行分组,请按照以下步骤进行分组:
}).GroupBy(g => g.WorkPlanReview.frequency).ToList();