LINQ Order BY

Larry Brister
Larry Brister used Ask the Experts™
on
In my query below, how do I do an order by on my Region Field?

            Dim Query = _
      (From Region In dataset1.Tables(0) _
      Select Region.Field(Of String)("Region")).Distinct().ToList

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2015
Commented:
You need an anonymous function:

Dim Query = _
            (From Region In dataset1.Tables(0) _
             Select Region.Field(Of String)("Region")).Distinct().OrderBy(Function (item) item).ToList

Open in new window

Larry Bristersr. Developer

Author

Commented:
Once again...
Kudos to kaufman!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial