2
這有什麼問題?LINQ to Entities不識別方法'Int32 Last [Int32]
int folderid = (from p in db.folder where p.isDefault == true select p.id).Last();
我得到這個錯誤
LINQ to Entities does not recognize the method 'Int32 Last[Int32]
(System.Linq.IQueryable`1[System.Int32])' method, and this method cannot be
translated into a store expression.
'FirstOrDefault()'如果集合爲空則不會炸掉它。但仍然是我+1,這是正確的方法。 – 2012-04-01 20:40:58
你不覺得'Single()'或'SingleOrDefault()'會更直觀嗎? – MarcinJuraszek 2012-04-01 20:42:22
如果集合爲空,異常將拋出。 是真的嗎? – MHF 2012-04-01 20:45:27