【发布时间】:2016-01-23 05:05:02
【问题描述】:
我有一个 MVC 应用程序,我想根据我的要求从 sql server 数据库中获取记录。主要是我有表“OfficeDetail”,其中一列是“ApprovedDate”,第二列是“ChildCount”。 “批准”包含批准用户文档的日期。第二个“ChildCount”包含整数值。我还在这个网站上搜索了另一个问题,但没有得到解决方案。我使用了两个 where 条件,所以为了获取记录,我编写了这段代码。
public IEnumerable<EmployeeModel> GetAllExpired()
{
DateTime my = DateTime.Today;
DBContext = new ConsumerNomineeFormEntities();
return (from f in DBContext.OfficeDetails
where (SqlFunctions.DateDiff("second",f.Date,my.Date)>90)
where (f.ChildCount>5)
select new EmployeeModel
{
XConsumer_Id = f.ConsumerNo_,
XApproved = f.Date,
XChildCount = f.ChildCount,
XTimeSpent = (f.Date - DateTime.Today).TotalDays
}).ToList();
}
【问题讨论】:
标签: c# entity-framework datetime