c# - 选择 Table.Value == 最大值

标签 c# sql linq

我有一个具有以下设计的 SQL 表:

TableSchedule:
Id
Description
ImportedDate

我可以导入大量项目,它们都将具有相同的 ImportedDate。

我如何编写一个 LINQ 查询来仅获取具有最新 ImportedDate 的条目?

var ResultSchedule =
    from a in Db.TableSchedule
    where a.ImportedDate == (Newest?)

最佳答案

试试这个

var ResultSchedule = 
from a in Db.TableSchedule 
where a.ImportedDate == (from item in DB.TableSchedule Select item.ImportedDate).Max() 

关于c# - 选择 Table.Value == 最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3875632/

相关文章:

mysql - 使用 LIKE 和 WHERE 的 SQL 搜索查询

c# - LINQ;从文本文件中选择行组

c# - LINQ 加入不同的结果集

c# - 我如何修改此 C# 代码,以便 Visual Studio 识别出我不是白痴?

c# - 将随机生成的颜色分配给值

c# - 变量不加其他变量值

mysql - 检测旧值是否不等于新值且旧值是否为 NULL

c# - byte[8] 到 bits[64] 解析

c# - 从 Internet Explorer 渲染图像

sql - JPA,获取所有元素