[英]LINQ to Entities does not recognize the method 'Int32 Last[Int32]
what's the problem with this ? 这是什么问题?
int folderid = (from p in db.folder where p.isDefault == true select p.id).Last();
i get this error 我得到这个错误
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.
Linq can not translate the Last()
to any valid sql statment. Linq无法将
Last()
为任何有效的sql语句。 So my suggestion would be to orderby decending
and Take(1)
所以我的建议是按
orderby decending
并Take(1)
Maybe something like this: 也许是这样的:
int? folderid =(
from p in db.folder
where p.isDefault == true
orderby p.id descending
select p.id
).Take(1).SingleOrDefault();
I don't know which to take so you might have to change the orderby p.id descending
to something that suites you. 我不知道该采取哪种方法,因此您可能必须将
orderby p.id descending
更改为orderby p.id descending
您的orderby p.id descending
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.