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”).ThenBy(“OtherProperty”);
.OrderBy(“Property desc”).ThenBy(“OtherProperty desc”);
.OrderByDescending(“Property”)
.ThenByDescending(“OtherProperty”);
.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 https://github.com/Grax32/OrderByString
Install the NuGet package from https://www.nuget.org/packages/OrderByString/