学习日记14、EF 时间段查询

m_Rep.GetList(a => System.Data.Entity.DbFunctions.DiffDays(DateTime.Now, a.EndDate) < date);

命名空间:  System.Data.Entity.Core.Objects
程序集:  EntityFramework(在 EntityFramework.dll 中)

语法
 
 
 
[SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "dateValue1")]
[DbFunctionAttribute("Edm", "DiffDays")]
[SuppressMessageAttribute("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "dateValue2")]
public static Nullable<int> DiffDays(
	Nullable<DateTimeOffset> dateValue1,
	Nullable<DateTimeOffset> dateValue2
)

参数

dateValue1
类型:System.Nullable<DateTimeOffset>
第一个日期/时间。
dateValue2
类型:System.Nullable<DateTimeOffset>
第二个日期/时间。

返回值

类型:System.Nullable<Int32>
第一个日期/时间和第二个日期/时间间隔的天数。
备注
 
 

无法直接调用此函数。 此函数只能出现在 LINQ to Entities 查询中。 此函数将被转换为数据库中对应的函数。

原文地址:https://www.cnblogs.com/Wxinchun/p/8733708.html