Grax Coding

Saturday, January 31, 2015

OrderByString enables string search parameters in LINQ OrderBy clauses

Here is something new to play with.  I just released a package that adds commands for OrderBy that take strings for property name and direction.

Usage is very flexible.  Here are some of the different ways to use the new commands:

 .OrderBy("Property desc").ThenBy("OtherProperty desc");
 .OrderBy("Property desc, OtherProperty asc");
 .OrderBy("Property, OtherProperty desc");

Since these commands parse the strings and then call the standard IQueryable/IEnumerable commands for OrderBy and ThenBy, these commands will still work with your EntityFramework queries or any other LINQ queries.

Get or review the source at and install the NuGet package from