score:15
Accepted answer
You don't assign result of OrderByDescending
leaves = leaves.OrderByDescending(e => e.StartDate).ToList();
or do
leaves = leaves.Concat(otherleaves).OrderByDescending(e => e.StartDate).ToList();
score:0
OrderByDescending
doesn't order a list, it returns a new ordered IEnumerable
. So use the result of OrderByDescending
to display your items.
score:1
OrderByDescending
does not "sort in place". It rather returns an IOrderedEnumerable
that you must assign to a variable.
var orderedLeaves = leaves.OrderByDescending(e => e.StartDate);
Source: stackoverflow.com
Related Articles
- OrderByDescending not working properly in Linq
- Linq code not working properly
- LINQ Source Code Available
- creating Linq to sqlite dbml from DbLinq source code
- Dynamic Linq GroupBy Select not working properly
- source code for LINQ 101 samples
- Linq query is not working while sql is working properly
- Linq query of left outer join not properly working
- C# LINQ code not working for XML parse
- LINQ Query not working properly ASP.NET CORE MVC
- Linq Code with Distinct or GroupBy not working
- LINQ query not working properly
- c# Linq or code to extract groups from a single list of source data
- Updating List using LINQ working when execute from Immediate window, not from code direct
- Linq Where condition is not working properly using EF
- Update using Linq query not working properly
- Querying datatable with Linq not working properly
- Dynamic LINQ Query not working properly with Taxonomy field
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Distinct not working with LINQ to Objects
- Linq code to select one item
- How are people unit testing code that uses Linq to SQL
- C# Linq All & Any working differently on blank array
- C# LINQ .Any not working on DocumentDb CreateDocumentQuery
- jqgrid with asp.net webmethod and json working with sorting, paging, searching and LINQ -- but needs dynamic operators
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- Using Linq Except not Working as I Thought
- Syntax to execute code block inside Linq query?
- Generic List .First not working LINQ
- How to use EXIST and NOT EXIST clause using lambda expression
- how to get all the products that start with J in Linq? ps Simple
- Replacing values in a list inside a Linq query with values from a dictionary
- Dynamic lambda using an expression builder for select
- How do you do a join in LinqToSQL?
- How to use filter result with list integer in IQueryable
- Linq to get row with a minimum value of a column but based on another column value
- Combining two expressions (Expression<Func<T, bool>>)
- how to parse this xml with LINQ
- Linq split collection into two based on having children (parentId)
- Transforming a one to many sql query into a List of nested classes
- SingleOrDefault linq method throwing exception
- Grouping by two words using LINQ
- Return Original datatype after LINQ group by
- How performance can change using greedy LINQ operators?
- VB.net LINQ filter on multiple columns
- Generate a list holding/making mapping between a List<string> and a List<int>
- C# MVC ViewModel Returns Null - Postback
- Oracle query to LINQ
- Linq to entity. Nested projection