我有以下......
Dim dc as New DBDataContext
Dim q = From c In dc.Customers _
Order By c.City _
Select c.City _
Distinct
我的问题是虽然查询产生了一个不同的列表但它没有排序。我如何实现这一目标。
答案 0 :(得分:1)
Order By c.City
修复后会移动Distinct
吗?
Dim q = From c In dc.Customers _
Select c.City _
Distinct _
Order By City
或如果以上不起作用,您可以在客户端进行订购操作:
Dim result = q.OrderBy(Function(x) x)
答案 1 :(得分:1)
如果q是未排序的查询,那么您可以在之后对其进行排序
Dim sorted = From c in q order by c select c
或
q = From c in q order by c select c