我有一個誤區之二串:LINQ到實體比較Where子句
LINQ to Entities does not recognize the method 'Int32 ToInt32(System.String)' method, and this method cannot be translated into a store expression.
的一段代碼:
plist= plist.Where(p => Convert.ToInt(p.Period) >= syslockPeriod);
p.Period例如:201206
的plist是IQueryable。 p.Period是字符串類型。 sysLockPeriod是int。
如何解決?
你不能在linq2entities中使用Convert.ToInt ...。順便說一句,爲什麼Period是一個字符串,如果它是一個int? – 2012-07-09 07:25:24
它不是int,因爲在Sql Server數據庫中最初Period是字符串類型。我不知道爲什麼它不是一個整數)) – loviji 2012-07-09 07:27:45
那麼,我必須是一個int,可以更改爲Sql Server中的int,也許? – 2012-07-09 07:30:58