Reputation: 527
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.
Upvotes: 3
Views: 3910
Reputation: 31249
Linq can not translate the Last()
to any valid sql statment. So my suggestion would be to orderby decending
and 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.
Upvotes: 7