3
我有以下查詢在數據庫中調用包含通過「直接事件,這些線路的方法時,返回選擇通過LINQ最後一個記錄失敗,
using (Entities ent = new Entities())
{
Loaction last = (from x in ent.Locations select x).Last();
Location add = new Location();
add.id = last.id+1;
//some more stuff
}
以下錯誤選擇的最後一個記錄「不能識別方法」 「關於ext.net:
LINQ to Entities does not recognize the method 'Prototype.DataAccess.Location Last[Location]
(System.Linq.IQueryable`1[Prototype.DataAccess.Location])' method,
and this method cannot be translated into a store expression.
表結構如下:
int ident IDENTITY NOT NULL,
int id NOT NULL,
varchar(50) name NULL,
//some other varchar fields
看看這個問題:http://stackoverflow.com/questions/7293639/linq-to-entities-does-not-recognize-the-method-last-really – 2013-03-05 08:56:00