我有一個smalldatetime字段,我試圖轉換爲LINQ中的字符串。 這是我當前的代碼:LINQ中的Smalldatetime ToString
var entities = from a in dbcontext.Article
where a.PubDateTime.ToString("ddMMyyyy") == pubDate
select a;
不過,我得到以下錯誤:
LINQ to Entities does not recognize the method 'System.String ToString(System.String)' method, and this method cannot be translated into a store expression.
我看了幾個帖子,但是我似乎無法得到它的工作。 任何指針都會很棒。
可以先將'pubDate'轉換爲DateTime嗎? –
爲什麼不使用'DateTime.Compare'來代替? –