Fork me on GitHub

Linq to entity时间比较函数

System.Data.Objects.EntityFunctions.DiffDays();
        //
        // 摘要:
        //     调用 DiffDays 规范函数。有关 DiffDays 规范函数的信息,请参见Date and Time Canonical Functions
        //     (Entity SQL)。
        //
        // 参数:
        //   dateValue1:
        //     有效日期。
        //
        //   dateValue2:
        //     有效日期。
        //
        // 返回结果:
        //     dateValue1 和 dateValue2 之间的天数。
        [EdmFunction("Edm", "DiffDays")]
        public static int? DiffDays(DateTime? dateValue1, DateTime? dateValue2);
        public IList<Meeting> GetMeetingListByDate(DateTime startTime)
        {
            return db.Meeting.Where(x => System.Data.Objects.EntityFunctions.DiffDays(x.StartTime, startTime) == 0)
                .OrderByDescending(x => x.StartTime).ToList();
        }

 

posted @ 2012-11-12 16:50  Nick.Chung  阅读(541)  评论(0编辑  收藏  举报