我只需要在涉及datetime
字段的Linq查詢中僅比較日期。但是,語法如下導致以下錯誤消息使用Linq查詢將日期與DateTime字段進行比較
The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
有誰知道如何提取剛剛日期了datetime
場的?
var duplicate = from a in _db.AgentProductTraining
where a.CourseCode == course.CourseCode &&
a.DateTaken.Date == course.DateTaken.Date &&
a.SymNumber == symNumber
select a;
如果日期在不同的日期,但是間隔時間不到一天,例如'2013年1月5日23:30:00'和'2013年1月6日01:30: 00'? – dasblinkenlight 2013-02-08 18:21:50
我不這麼認爲:http://www.sqlteam.com/article/datediff-function-demystified – IronMan84 2013-02-08 18:25:40
感謝您的鏈接! – dasblinkenlight 2013-02-08 18:34:07