2014-04-27 174 views

回答

2

排序您的记录由Id降序为了再拿到第一个记录:

db.Records.OrderByDescending(x => x.Id).First(); 
1

使用MAX()在你的SQL查询..

为例(如果我们想最大的无记录表的id列

Select Max(id) from records-table 

编辑:返回记录,不o NLY ID =>

Select id, Name, Description, Date, Owner from records-table where id = (Select Max(id) from records-table) 
+0

但不返回该记录,将返回的最大Id值 –

+0

@ Selman22其更新 – sihirbazzz

+0

从性能视图该解决方案是不是最好的之一,因为它包含一个子选择在wehre clausel。 – Andre