score:1

Accepted answer

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.


Related Query

More Query from same tag