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



Leave a Reply