web-dev-qa-db-ja.com

VB.NETのLINQでのORDERBYの構文は何ですか?

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
17
Annie Chen
qry = qry.OrderBy(Function(obj) obj.PropertyToSortBy)
29
Mehrdad Afshari

クエリの代替構文(よりクリーンなIMO):

Dim qry = From lst In cxt.zipcodes _
          Select lst.state Distinct _
          Order By state
12
Meta-Knight
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
0
Wesam