score:1
It's not that the IComparer is not supported, it is that in Linq-to-Sql, an OrderBy() must be translated to a T-Sql operation. If it allows you to specify criteria for comparisons, The C# code behind it would have to be executed by SQL server to use it.
If you need to do something in Linq-To-Sql that is not supported but which can be done in T-SQL, you can always get around it by using a stored procedure, which work splendidly with Linq-to-Sql. If that it inconvenient, you can call the ToList() method to invoke the execution and then sort it in memory. The practicality of this depends on the size of the data and how much of it you wished to fetch (such as when implementing pagination).
score:1
Yes. Linq-to-SQL translates your lambda expressions directly into sql, so it obviously cannot handle arbitrary code. You could use ToList()
to force query execution, and then perform your OrderBy
on that list.
Source: stackoverflow.com
Related Articles
- LINQ orderby vs IComparer
- LINQ Source Code Available
- multiple orderby in this linq code
- LINQ Lambda efficiency of code groupby orderby
- creating Linq to sqlite dbml from DbLinq source code
- Passing an IComparer parameter to custom LINQ OrderBy extension method
- source code for LINQ 101 samples
- c# Linq or code to extract groups from a single list of source data
- Custom IComparer in LINQ OrderBy Lambda expression
- Dynamic LINQ OrderBy on IEnumerable<T> / IQueryable<T>
- LINQ Orderby Descending Query
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- LINQ OrderBy versus ThenBy
- Linq code to select one item
- How do I specify the Linq OrderBy argument dynamically?
- LINQ OrderBy with more than one field
- How are people unit testing code that uses Linq to SQL
- Linq OrderBy against specific values
- LINQ OrderBy is not sorting correctly
- Custom sort logic in OrderBy using LINQ
- LINQ orderby on date field in descending order
- C# LINQ Orderby - How does true/false affect orderby?
- Use own IComparer<T> with Linq OrderBy
- C# linq sort - quick way of instantiating IComparer
- C# Linq OrderBy filtering null or empty values to be last
- How to OrderBy an integer in a string field in a Linq query
- LINQ OrderBy not ordering .. changing nothing .. why?
- Linq syntax for OrderBy with custom Comparer<T>
- How to apply multiple orderby in linq query
- Can you overload Sum to add custom types
- LINQ subquery with AND operator displays no results
- How to get the sum of a list after I grouped it
- return list after Join two list from method
- Why does this Linq method throw a Null Reference Exception
- LINQ Query with both CASE statement and SUM function
- How to check if a list of object contains an object with a specified properties
- Difference between "System.Linq.Dynamic", "Dynamic Expression API" and "DynamicLINQ" on NuGet?
- Linq data mapping with Ms Access database: "Missing semicolon (;) at end of SQL statement."
- EF-Code First: Unable to create a constant value of type ''. Only primitive types ('such as Int32, String, and Guid') are supported in this context
- Intercepting and overriding a comparison expression in an object that otherwise delegates to Linq to Objects provider
- Group a sorted list without affecting the sorting in linq
- Display contains for integer array using ternary operator in C#
- EF 6: Dynamically copy a an entry of a DbSet
- How to get a Cartesian product of a list containing lists?
- Reading a key/value pair to a dictionary by passing the path of the .config file c#
- LINQ select all items of all subcollections that contain a string
- IQueryable<out T> Where only class name is known
- SQL "in" type behaviour with a WCF Dataservice
- How can I concatenate a where clause using OR on LINQ?