LINQ - OrderBy Method and Multiple Fields

Just a friendly helpful tip - if you are using LINQ and have, for example, a list of objects, you can use the OrderBy() method to order it. But in order to order it by additional column criteria, use the following:

listView.DataSource = myList.OrderBy(i => i.Field1).ThenBy(i => i.Field2);

Additionally, the OrderByDescending() and ThenByDescending() methods also exist to assit you.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

0 Responses to “LINQ - OrderBy Method and Multiple Fields”


  1. No Comments

Leave a Reply