0
林有一个问题,我不能拿过去,这里是我的控制器报告 -获取一周的LINQ to SQL为谷歌图表
var week = DateTime.Now.Date.AddDays(-7);
List<LeaveChartVM> data = new List<LeaveChartVM>();
using (ApplicationDbContext db = new ApplicationDbContext())
{
data = (from u in db.UserProfiles
select new LeaveChartVM
{
Users = (from up in db.UserProfiles
select up).Count(),
OnLeaveToday = (from tol in db.CalendarData
where (today >= tol.StartTime && today <= tol.EndTime)
select tol).Count(),
SickLeave = (from sl in db.CalendarData
where sl.LeaveType == "5"
select sl).Count(),
AnnualLeave = (from al in db.CalendarData
where al.LeaveType == "1"
select al).Count()
}).Distinct().ToList();
}
能有人帮我只有这个星期返回的数据吗?我设法返回今天的疾病并离开,但我想创建一个线性图表,返回本周的数据。
添加到这是信息wasnt很大,继承人的表结构的calendarDatas -
[Subject]
,[Description]
,[StartTime]
,[EndTime]
,[AllDay]
,[Recurrence]
,[RecurrenceRule]
,[LeaveType]
,[StartTimeZone]
,[EndTimeZone]
,[UserId]
,[EventStatus]
,[ApporovedId]
,[ApprovedDate]
,[Duration]
,[EventAction]
,[EventDate]
,[uid]
,[colourId]
,[UserProfiles_Id]
,然后也为的UserProfiles -
什么,我想回是人都上年度过去7个工作日以及当天的假和病假。
请张贴*有关*代码只和的CalendarData的结构。当我们甚至不知道您是否有* DateTime列时,如何获得某个星期的数据是不可能的。 –
我认为它不是内置的。 您可以制作if语句。 如果sonday ...得到6天后... 如果周一...之前拿到的一天后,5天... ...... – 2016-08-18 09:37:57
@SimonR - 你的代码是混乱。您正在为每个用户选择不同的东西,而无需将其“绑定”到特定用户。 +这个问题本身约1天与一周。请说出你想要的数据输出是什么,以及不同的表格如何看起来像 –