C# 不同字段上的实体核心与where字段不同

C# 不同字段上的实体核心与where字段不同,c#,entity-framework-core,C#,Entity Framework Core,我需要从某个日期开始对所有记录进行选择,但在另一个字段上收到一个不同的字段 以下是我在尝试获得不同结果之前目前的情况 var entity = _context.ClientOrder .Where(s => s.DateScanned == datetime) .OrderBy(s => s.Sequence) .Include(s => s.ClientVehicle) .The

我需要从某个日期开始对所有记录进行选择,但在另一个字段上收到一个不同的字段

以下是我在尝试获得不同结果之前目前的情况

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();

“在另一个字段上使用distinct”听起来像GroupBy
distinct()
将检查类中每个属性的值,如果每个属性的值相同,则消除重复项。如果属性值中的任何一个不同,它会将其视为不同的记录Hey@DavidBrowne Microsoft我现在尝试使用GroupBy,但它不起作用。你能确认我的语法或者它应该是什么样子吗?GroupBy(key,collection)对的输出。每个不同的GroupId可能有很多行。