[{"data":1,"prerenderedAt":97},["ShallowReactive",2],{"/2025/10/04-entity-framework-sorting-ordering-and-dynamic-linq":3},{"id":4,"title":5,"body":6,"date":88,"description":73,"extension":89,"meta":90,"navigation":91,"path":92,"robots":93,"seo":94,"stem":95,"__hash__":96},"posts/2025/10/04 Entity-Framework-sorting-ordering-and-Dynamic-LINQ.md","04 Entity Framework Sorting Ordering And Dynamic LINQ",{"type":7,"value":8,"toc":85},"minimark",[9,18,25,28,53,55,58,61,74],[10,11,13],"post-title",{":date":12},"date",[14,15,17],"h1",{"id":16},"entity-framework-sorting-ordering-and-dynamic-linq","Entity Framework Sorting/ Ordering and Dynamic LINQ",[19,20,21],"notes",{},[22,23,24],"p",{},"This is a repost from my old blog. First posted in 10/2/2018.",[26,27],"br",{},[22,29,30,31,39,40,52],{},"One of my coworkers would like me to update my ",[32,33,38],"code",{"className":34},[35,36,37],"bg-gray-200","p-2","rounded","IEnumerable SortBy"," extension method to support multiple columns. As I was working on it, I stumbled upon a nice StackOverflow question on ",[41,42,48,49],"a",{"href":43,"rel":44,"className":46},"https://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet-iqueryablet",[45],"nofollow",[47],"text-blue-600","Dynamic LINQ OrderBy on IEnumerable",[50,51],"t",{},".",[26,54],{},[22,56,57],{},"They are all awesome. I decided to try Dynamic LINQ by adding it through Nuget. However, I soon found that Dynamic LINQ only support property names. In some cases, we want to be able to sort by specifying column attribute value, so I still use my own code which works just fine although it might not be optimized for performance.",[22,59,60],{},"For example in VB.NET:",[62,63,64],"code-block",{},[65,66,71],"pre",{"className":67,"code":69,"language":70},[68],"language-text","Public Class Customer\n    \u003CColumn c_name=\"\">\n    Public Property Name As String\n\n    \u003CColumn c_age=\"\">\n    Public Property Age As Integer\nEnd Public\n\nDim sortedByName = dbContext.Customers.AsEnumerable().SortBy(\"c_Name, c_Age DESC\")\n","text",[32,72,69],{"__ignoreMap":73},"",[22,75,76,77],{},"The gist for my code can be found in:\n",[78,79,81],"span",{"className":80},[47],[41,82,83],{"href":83,"rel":84},"https://gist.github.com/nikyodo85/202fc2d417d9eb030d30896ccc862b7d",[45],{"title":73,"searchDepth":86,"depth":86,"links":87},2,[],"2025-10-04T00:00:00.000Z","md",{},true,"/2025/10/04-entity-framework-sorting-ordering-and-dynamic-linq",null,{"title":5,"description":73},"2025/10/04 Entity-Framework-sorting-ordering-and-Dynamic-LINQ","F4zsRrD2E27e5PEGwxjl1nJGkdLnZbEg8rAG8TeuFVw",1785167452990]