Category Archives: C#

Recently I had to add ordering support to an application using the column names as strings, but the LINQ API accepts only Lambda expressions.
And to worsen my case, I needed it to work with IEnumerable, plus nested properties, so I decided to write this extension to fulfill these needs.

Normally you’d write:

list.OrderBy(p => p.Name);
list.OrderBy(p => p.Member.SubMember).ThenBy(p => p.AnotherMember);

Now, you can write:

list.OrderBy("Name");
list.OrderBy("Member.SubMember").ThenBy("AnotherMember");

It ended up being more friendly, and I hope it makes your life easier as well.