score:1
Seems that there isn't much of an answer to be made, so:
As pointed by SLaks the issue has been known for a long time but has never been fixed in the .NET Framework despite all the new releases (.Net 4.6.1 as of now) - https://connect.microsoft.com/VisualStudio/feedback/details/634949/orderbydescending-fails-in-linq-to-objects-when-a-comparer-returns-int-minvalue.
The only way to avoid this problem is to not return the Int32.MinValue
from CompareTo
implementations.
But as pointed by usr .Net Core has this issue fixed - https://github.com/dotnet/corefx/blob/35e03c78d89d02f2d3b4a1f8b277a35c88f45750/src/System.Linq/src/System/Linq/OrderedEnumerable.cs#L628
Source: stackoverflow.com
Related Articles
- OrderByDescending operates incorrectly due to integer overflow
- LINQ Source Code Available
- .NET 4 Code Contracts: "requires unproven: source != null"
- creating Linq to sqlite dbml from DbLinq source code
- Can't add a new record with an integer value into database by using linq from code C#
- source code for LINQ 101 samples
- List or Array of String Contain specific word in Html Source Code
- c# Linq or code to extract groups from a single list of source data
- Generated DBML code incorrectly marks returned columns as NOT NULL for stored procedures
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Value cannot be null. Parameter name: source
- Linq code to select one item
- C# - code to order by a property using the property name as a string
- How do I find the text within a div in the source of a web page using C#
- Roslyn failed to compile code
- Entity-framework code is slow when using Include() many times
- The data source does not support server-side data paging
- How are people unit testing code that uses Linq to SQL
- Entity Framework, Code First and Full Text Search
- OrderBy and OrderByDescending are stable?
- What does this C# code with an "arrow" mean and how is it called?
- How to resolve Value cannot be null. Parameter name: source in linq?
- The source contains no DataRows
- How to OrderBy an integer in a string field in a Linq query
- This operation would create an incorrectly structured document
- Could not find an implementation of the query pattern for source type 'System.Data.Entity.DbSet'
- How to count the number of code lines in a C# solution, without comments and empty lines, and other redundant stuff, etc?
- Is there an IEnumerable implementation that only iterates over it's source (e.g. LINQ) once?
- Entity Framework 6 Code First Custom Functions
- Dynamically Building LINQ-To-Entities Where Clause
- When does a library deserve the be called "Linq-something" or "something-Linq"?
- Can't insert NULL into varbinary column using LINQ
- entity framework distinct by field
- Fetch Entity Framework objects with partially loaded collections
- Query JSON using LINQ
- Which query has better performance to return an object which has the max value for a specific property?
- This LINQ statement crashes if one of the Properties is NULL. How can I fix this?
- How to group by 2 items of a list into another list
- How do I grab a single attribute from a Collection of objects that I group into a list?
- Index in the Select projection
- Combine the results of two columns in a select into one array with LINQ?
- Linq query to get the distinct values in a list
- LINQ nested grouping with multiple collections
- How to reuse a linq expression for 'Where' when using multiple source tables
- JSON.NET Argument Exception when creating JSON with LINQ
- Search missing numbers in sequence
- Why GuID is not generated when new record is Inserted
- LINQ - How to read ID which is Autonumber after submitting the data
- LINQ to MySQL query returns no result