Entity Framework – case insensitive Contains?

I know that this is not related directly to EF, but only solution I can think of is to alter DB table column collation to be Case Insensitive e.g.:

ALTER TABLE TABLENAME ALTER COLUMN COLUMNNAME nvarchar(100) COLLATE Latin1_General_CI_AS NULL

CI – case insensitive /
CS – case sensitive

AS – accent sensitive /
AI – accent insensitive (can also be useful)

If you can’t change collation of table column you can use direct query from EF with forcing collation

select * 
from table
where country collate Latin1_General_CI_AS != @country

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)