在Lambda表达式中使用Group By Having

本文关键字:Group By Having Lambda 表达式 | 更新日期: 2023-09-27 18:11:00

谁能帮我把下面的查询用Lambda表达式转换成LINQ ?

select idshiftschedule,Date from Teammateassignments 
where IdClinic = 19
group by IdshiftSchedule,DATE having COUNT(Date)>1

在Lambda表达式中使用Group By Having

这只是对后面的组的一个过滤器:

 var results = from item in assignments
               where item.IdClient == 19
               group item by new { item.IdShiftSchedule, item.Date } into g
               where g.Count() > 1
               select g.Key;

(我假设Count(Date) > 1实际上只是在计算组中的项目数量…我不清楚如果Date是可空的,它会做什么,例如。)