Subsonic ordering – OrderByDescending

So the subsonic documentation sucks. If you’re new to activerecord, linq and subsonic in general; you’ll find it fairly hard to construct basic queries. However once you’ve got it under control, it’s a piece of cake.

To sort your table using activerecord, use the following examples;

To sort ascending by a column called name

var categories = category.All().OrderBy(c => c.name);

To sort descendingby a column called name

var categories = category.All().OrderByDescending(c => c.name);

You can then just bind to your gridview/dropdown list or whatever you like.

            if (categories != null)
            {
                drp.DataSource = categories ;
                drp.DataBind();
            }

Related posts:

  1. How to fetch Last Record in Subsonic

Have a computer problem? Ask in our SUPPORT forum!

Receive Discounted Software

No bull. Want cheap discounts for common software products?
  • AntiVirus
  • Video editing tools
  • Web development tools
  • Registry Cleaners
  • Computer speed boosters!
Our editors get these products sent to us WEEKLY for review.

WE WANT TO PASS THESE DISCOUNTS ON TO YOU! (We honestly don't need them)

So whack your email in the box below and when we receive stuff we'll forward it to you! Its that simple.


Leave a Reply