Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order by with Collate clause | Entity Framework

I don't want to use array sorting on the web server it should be done on SQL server.

Microsoft does not support query(in EF) like this:

SELECT * FROM [Table_1]
ORDER BY [Table_1].field
COLLATE SQL_SwedishStd_Pref_Cp1_CI_AS

Any ideas? Thank you in advice...

like image 725
omoto Avatar asked Mar 22 '09 13:03

omoto


People also ask

What is collate SQL query?

Collations in SQL Server provide sorting rules, case, and accent sensitivity properties for your data. Collations that are used with character data types, such as char and varchar, dictate the code page and corresponding characters that can be represented for that data type.

Is EF case-sensitive?

By design, EF Core refrains from translating these overloads to SQL, and attempting to use them will result in an exception. For one thing, EF Core does know not which case-sensitive or case-insensitive collation should be used.

What is collation case-insensitive?

A case-insensitive collation ignores the differences between uppercase and lowercase letters for string comparison and sorting, whereas a case-sensitive collation does not. For example, in case-insensitive collation, “A” and “a” are equal.

Is Latin1_General_CI_AS case-sensitive?

So for example, Latin1_General_CI_AS is case-insensitive and accent-sensitive.


1 Answers

The Entity Framework does support a COLLATE clause in an ORDER BY in Entity SQL. I'm not aware of any way to do it with LINQ to Entities. Indeed, I don't know how to do it with any LINQ provider. I'm not sure it's possible.

like image 56
Craig Stuntz Avatar answered Sep 21 '22 12:09

Craig Stuntz