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