Can anyone help me to convert the below query to LINQ with Lambda expression.
select idshiftschedule,Date from Teammateassignments
where IdClinic = 19
group by IdshiftSchedule,DATE having COUNT(Date)>1
That's just a filter on the groups afterwards:
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;
(I'm assuming that Count(Date) > 1
is really just counting the number of items in the group... it's not clear to me what it would do if Date
is nullable, for example.)
See more on this question at Stackoverflow