c# - Entity Core Distinct 在不同字段上作为 where 字段
问题描述
我需要对某个日期的所有记录进行选择,但在另一个字段上收到不同的记录。
这是我目前在尝试获得不同结果之前所拥有的。
var entity = _context.ClientOrder
.Where(s => s.DateScanned == datetime)
.OrderBy(s => s.Sequence)
.Include(s => s.ClientVehicle)
.ThenInclude(s => s.ClientDetails)
.ToList();
我希望有这样的东西
var entity = _context.ClientOrder
.Where(s => s.DateScanned == datetime)
.Select(s => s.GroupId)
.Distinct()
.OrderBy(s => s.Sequence)
.Include(s => s.ClientVehicle)
.ThenInclude(s => s.ClientDetails)
.ToList();
根据建议,我现在正在尝试使用 GroupBy() 但它似乎不起作用。我的语法错了吗?
var entity = _context.ClientOrder
.GroupBy(s => s.GroupId)
.Where(s => s.DateScanned == datetime)
.OrderBy(s => s.Sequence)
.Include(s => s.ClientVehicle)
.ThenInclude(s => s.ClientDetails)
.ToList();
解决方案
推荐阅读
- python - 熊猫分组和过滤
- python - 通过属性访问嵌套 dics 的类通过 print 和 __dict__ 显示不同的值
- spring - 使用 Spring Security 保护 XHTML 站点
- database - 如何在jmeter的帮助下,当有不同的Database sql server,不同的应用程序服务器时检查负载
- sorting - 排序时查询多列并结合列标题
- return - 如何从 raku sub 返回 2 个哈希?
- java - “线程“主”org.openqa.selenium.WebDriverException 中的异常:断开连接:收到 Inspector.detached 事件”与 Selenium Java
- amazon-web-services - 带有 localstack 的无服务器框架,在哪里查看错误输出
- node.js - 发布到 npm 时如何忽略子 package.json 文件
- javascript - 库应该作为打字稿文件提供吗?