【发布时间】:2013-12-10 21:38:26
【问题描述】:
我知道这应该是一个已解决的问题,但我无法让记录在案的解决方案为我工作。下面的代码假设在 distinct 之后进行排序,但事实并非如此。我参考了这个帖子:LINQ to SQL does not generate ORDER BY when DISTINCT is used?
fyMonth = (From f In DbContext.FYMonth
Select f.Month).Distinct().OrderBy(Function(n) n).ToList()
我尝试时遇到错误:
OrderBy(Function(n) n.SortOrder)
有什么想法吗?
【问题讨论】:
-
哦,你不能在 orderby 中使用 n.SortOrder,因为你没有将它包含在你的结果集中......你只是选择了 Month。