这有什么问题呢?
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.发布于 2012-04-02 04:33:04
Linq无法将Last()转换为任何有效的SQL语句。所以我的建议是给orderby decending和Take(1)
可能是这样的:
int? folderid =(
from p in db.folder
where p.isDefault == true
orderby p.id descending
select p.id
).Take(1).SingleOrDefault();我不知道该选哪一个,所以你可能得把orderby p.id descending换成适合你的。
https://stackoverflow.com/questions/9967990
复制相似问题