0
爲什麼這段代碼拋出System.NotSupportedException
告訴The specified method 'int? DateDiff(string, DateTime?, DateTime?)' on the type 'System.Data.Objects.SqlClient.SqlFunctions' cannot be translated into a LINQ to Entities store expression
,儘管DateDiff具有EdmFunction屬性?將Entity Framework中的DateTime與Sql Server Compact數據庫進行比較
context.Users.Where(f => System.Data.Objects.SqlClient.SqlFunctions.DateDiff("second", f.LastLogOn, somedatetime) < 0)
感謝的答案,但是這是不SQLCE SQL服務器,它不支持任何比較比則DateDiff等功能。 – Parsa 2010-07-07 06:48:28
據我瞭解,這個函數會被翻譯成DateDiff。試試看:) – 2010-07-07 07:52:57
對於實體框架版本6,考慮使用'DbFunctions.DiffSeconds' – Dherik 2015-05-11 17:42:47