我是 Linq 的新手,VB 中 order by 的语法是什么?
Dim cxt As New datContext
Dim qry = (From lst In cxt.zipcodes _
Select lst.state).Distinct
qry = qry.OrderBy()
我的简单 SQL 语句将是这样的:
Select distinct state from zipcodes
order by State
我是 Linq 的新手,VB 中 order by 的语法是什么?
Dim cxt As New datContext
Dim qry = (From lst In cxt.zipcodes _
Select lst.state).Distinct
qry = qry.OrderBy()
我的简单 SQL 语句将是这样的:
Select distinct state from zipcodes
order by State
qry = qry.OrderBy(Function(obj) obj.PropertyToSortBy)
查询的替代语法(更清晰的 IMO):
Dim qry = From lst In cxt.zipcodes _
Select lst.state Distinct _
Order By state
Dim cxt As New datContext
Dim qry = (From lst In cxt.zipcodes OrderBy lst.state).Distinct.tolist
Dim statelst = qry.Select(Function(o) o.state).ToList