Skip to content
Extension methods to use strings in LINQ OrderBy and ThenBy methods
C#
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
OrderByExtensions
OrderByExtensionsTests
docs
.gitattributes
.gitignore
LICENSE
OrderByExtensions.sln
README.md

README.md

OrderByString

Extension methods to use strings in LINQ OrderBy and ThenBy methods Enable the extensions methods by including a reference and a "using OrderByExtensions;" statement

Supports the following formats:

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

.OrderBy and .ThenBy default to ascending, OrderByDescending and ThenByDescending default to descending

"asc" or "desc" in the text takes precedence over the default from the command so that ().OrderBy("Property asc") does the same thing as ().OrderByDescending("Property asc")

You can’t perform that action at this time.