问题描述
SELECT DocentShiftSchedule.DocentAssigned,COUNT(*)AS NumShifts,DocentInfo。[MaxDaysPerMonth]
。从(ScheduledEvent RIGHT JOIN DocentShiftSchedule
关于ScheduledEvent.EventId = DocentShiftSchedule .EventId)
INNER JOIN DocentInfo ON DocentShiftSchedule.DocentAssigned = DocentInfo。[索引]
,其中((月([ScheduledEvent] [天])= 6)和(年份([ScheduledEvent]。[日])= 2010))
GROUP BY DocentShiftSchedule.DocentAssigned,DocentInfo.MaxDaysPerMonth,DocentInfo.MaxDaysPerMonth
。具有(计数(*)> = [DocentInfo] [MaxDaysPerMonth])
如何在LINQ C#中执行此操作?特别是,我遇到了"Group By"的问题。和"有'部分。我现在正在这里:来自se在ScheduledEvents中
加入dss在DocentShiftSchedules上se.EventId等于dss.EventId
加入d在dss.DocentAssigned中的DocentInfo等于d.Index
其中se.Day> = new DateTime(2010,6,1)&&
se.Day< =新日期时间(2010年,6,30)
的OrderBy d.Index
选择新的
{
DIndex = d.Index,
MaxDays = d.MaxDaysPerMonth
}
跨度>
SELECT DocentShiftSchedule.DocentAssigned, Count(*) AS NumShifts, DocentInfo.[MaxDaysPerMonth] FROM (ScheduledEvent RIGHT JOIN DocentShiftSchedule ON ScheduledEvent.EventId = DocentShiftSchedule.EventId) INNER JOIN DocentInfo ON DocentShiftSchedule.DocentAssigned = DocentInfo.[Index] WHERE ((Month([ScheduledEvent].[Day])=6) AND (Year([ScheduledEvent].[Day])=2010)) GROUP BY DocentShiftSchedule.DocentAssigned, DocentInfo.MaxDaysPerMonth, DocentInfo.MaxDaysPerMonth HAVING (Count(*)>=[DocentInfo].[MaxDaysPerMonth])
How do I do this in LINQ C#? In particular, I'm having trouble with the "Group By" and "Having' part. I'm currently at this:from se in ScheduledEvents
join dss in DocentShiftSchedules on se.EventId equals dss.EventId
join d in DocentInfo on dss.DocentAssigned equals d.Index
where se.Day >= new DateTime(2010, 6, 1) &&
se.Day <= new DateTime(2010, 6, 30)
orderby d.Index
select new
{
DIndex = d.Index,
MaxDays = d.MaxDaysPerMonth
}
这篇关于分组/有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!