【发布时间】:2014-03-09 14:15:55
【问题描述】:
using (EPOSEntities1 db = new EPOSEntities1())
{
List<ActionPerformed> PLUlist = db.ActionPerformeds.ToList();
ActionPerformed Latest_PLU = PLUlist.OrderByDescending(x => x.Date).FirstOrDefault();
}
这将返回最后存储的记录。但是,我现在在 File_Name 表中添加了另一列,如何在其中添加 where 子句来表示 orderByDescending 以获取最新文件,然后从那里获取 file_Name 为“Sales”的第一条记录。??
例如
File_Name Date
12) Products 11/02/2014
13) Sales 11/02/2014
14) Products 11/02/2014
这将返回记录 13??
【问题讨论】:
-
为什么要将整个列表拉入内存以过滤掉一条记录,而不是在数据库中进行所有过滤?
标签: c# asp.net asp.net-mvc linq asp.net-mvc-3