如何比较date属性可以为空的日期?

时间:2016-07-03 08:28:03

标签: c# entity-framework linq

我首先使用Entity Framework 6代码。

在我的实体课中,我有这个属性:

{
    "title": "My Article",
    "comments": [
        {
            "content": "my first comment",
            "added_by": {
                "username": "John"
            }
        },
        {
            "content": "my second comment",
            "added_by": {
                "username": "Smith"
            }
        }
    ]
}

在某些时候,我使用Linq实体从public class DamageEvent : IEntity { public int SiteObjectId { get; set; } public DateTime? CreateDate { get; set; } } 表中获取记录,使用Where子句比较年份和月份:

DamageEvent

但由于_dmRepository.Get().Where(i=>i.CreateDate.?) 属性可以为空,我在智能感知选项中没有选择CreateDateCreateDate.Year

如何从CreateDate.Month表中获取按年和月比较的记录?

0 个答案:

没有答案
相关问题