Web5 apr. 2011 · The Group entity has the properties GroupID, CategoryID (foreign key), Category (relationship), GroupName, and SortOrder. In C# syntax the problem query would be (I hope I've translated it correctly): var results = _context.Groups.OrderBy (g => g.Category.SortOrder).ThenBy (g => g.SortOrder).ToList Gavin WebThese two methods, namely ThenBy and ThenByDescending, enable you to specify additional sort criteria to sort a sequence. ThenBy and ThenByDescending also return …
[Solved] Multiple Order By with LINQ 9to5Answer
WebThe ThenBy and ThenByDescending extension methods are used for sorting on multiple fields. The OrderBy () method sorts the collection in ascending order based on specified … Web12 aug. 2024 · The next best thing is Linq with OrderBy and ThenBy. In the end, the solution I currently have is based on this, although the code is somewhat fragile. ... I will simplify the problem and eliminate the custom sorting in order to illustrate the issue with the Linq code. A table with people that have first, last and middle names is sorted by ... hifreq变频器
Using OrderBy and ThenBy on columns with the same name in …
WebThis post will discuss how to sort a list of objects against the multiple fields in C#. 1. Using LINQ To create a sorted copy of the list, we can use LINQ’s OrderBy () method. To compare objects against subsequent fields, call the ThenBy () method (or ThenByDescending ). WebThese two methods, namely ThenBy and ThenByDescending, enable you to specify additional sort criteria to sort a sequence. ThenBy and ThenByDescending also return an IOrderedEnumerable, which means any number of consecutive calls to ThenBy or ThenByDescending can be made. Note Web3 mai 2024 · 複数のキーが指定される場合は、加えてThenBy ThenByDescendingも使用しています。 これらの引数となるラムダ式を、処理内部で動的に生成しています。 単一キーによるソート処理では、以下のように動的ソートを実現しています。 how far is brick nj from philadelphia