.Distinct() 问题后的 LINQ .Take()

LINQ .Take() after .Distinct() issue

所以我正在使用 LINQ 和以下(经过清理的)代码进行数据库查询:

var dateList =
            Table1.Where(t1 => t1.column1.Contains(stringUsed)) //stringUsed is a parameter of the method containing this code
                .Join(Table2, t1 => t1.columnName2, t2 => t2.columnName2,
                    (t1, t2) => new {t1, t2})
                .Join(Table3, t1t2 => t1t2.t1.column3, t3 => t3.column3,
                    (t1t2, t3) => new {Date = t3.column4})
                .Select(d => d.Date.Value) //Dates are stored as a DateTime? and I need to convert it to DateTime here
                .Distinct()
                .ToList();

最终结果是一个包含 2000 多个唯一日期的列表(一切都很好)。根据用户要求,我只需要收集查询创建的最新 90 条记录的日期(数据已在数据库中排序,因此无需在此处执行此操作)。

当我尝试在 .Distinct().ToList() 之间插入 .Take(90) 时,我的问题就来了。结果是一个只有 13 条记录的列表。我在这里和其他地方搜索过,看看是否有其他人遇到过这个问题,但没有找到任何东西。有什么想法吗?

支持@usr 帮助解决这个问题。这是将根据需要提取 90 条记录的代码:

var dateList =
            Table1.Where(t1 => t1.column1.Contains(stringUsed)) //stringUsed is a parameter of the method containing this code
                .Join(Table2, t1 => t1.columnName2, t2 => t2.columnName2,
                    (t1, t2) => new {t1, t2})
                .Join(Table3, t1t2 => t1t2.t1.column3, t3 => t3.column3,
                    (t1t2, t3) => new {Date = t3.column4})
                .Select(d => d.Date.Value) //Dates are stored as a DateTime? and I need to convert it to DateTime here
                .Distinct()
                .OrderByDescending(d => d)
                .Take(90)
                .ToList();

显然添加 .OrderBy() 是需要做的。谢谢大家。