How do I perform Date Comparison in EF query?

后端 未结 11 1334
悲哀的现实
悲哀的现实 2020-11-30 07:33

Please help. I am trying to figure out how to use DATE or DATETIME for comparison in a linq query.

Example: If I wanted all Employee names for those who started befo

11条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 07:53

    That should work. Are you sure that there isn't another part of the query that triggered the exception? I have several instances of queries of the form

    var query = from e in db.MyTable
                where e.AsOfDate <= DateTime.Now.Date
                select e;
    

    in my code.

提交回复
热议问题