How can I execute case-sensitive comparisons?

session.Query.All<customer>().Where(c => c.Name == "john")

This will return customers named "John" and "JOHN".

asked Mar 25 '11 at 03:43

ara's gravatar image


Hello Ara,

Which collation is used in your database? If collation is Xxx_CS (case sensitive) then case-sensitive search will be executed properly out of the box.

(Mar 25 '11 at 05:03) Dmitri Maximov Dmitri%20Maximov's gravatar image

Hi Dmitri,

In Azure, the server and DB collations are CS, and you can't change them. I was looking for a way to generate COLLATE in my query, such as: "select * from Customer where Name = @name COLLATE Xxx_CI and Name = @name" (the predicate is duplicated so that the second allows the query optimizer to use an index seek).

For other readers, I've realized that you can set collation at column level... if you want case sensitive searches on particular columns.


(Mar 25 '11 at 16:57) ara ara's gravatar image

Anyway, this isn't crucial. I'll work around it. Thanks!

(Mar 25 '11 at 17:58) ara ara's gravatar image

The question has been closed for the following reason "Other" by ara Mar 25 '11 at 17:59

powered by OSQA