r.User.FirstName.ToLower().Contains(fullN" /> r.User.FirstName.ToLower().Contains(fullN" /> r.User.FirstName.ToLower().Contains(fullN"/>

How to set Turkish collation on postgres database using EF code first

234 Views Asked by At

my database records have strings with Turkish "İ" and I have the linq query like below:

query=query.where(r=>r.User.FirstName.ToLower().Contains(fullName.ToLower())

in the database I have user with name of "İbrahim"

searching about fullName=İbrahim gives me right result searching about fullName=ibrahim gives me wrong result

first I tried to send culture info inside linq query like this:

var culture = new CultureInfo("tr-TR", false);
r.User.FirstName.ToLower(culture)

but having culture info inside database connected LINQ query gives exceptions

then

I tried to define my postgres database with Turkish collation throw EF like this:

modelBuilder.UseDatabaseTemplate(“template0”);
modelBuilder.UseCollation(“C”);
modelBuilder.Entity().Property(p => p.Name).UseCollation(“tr-TR-x-icu”);
modelBuilder.UseTablespace(“pg_default”);

but I got this exception:

pg_default LC_COLLATE "C"; Npgsql.PostgresException (0x80004005): 22023: new collation (C) is incompatible with the collation of the template database (English_United States.1252)

any solutions ?

0

There are 0 best solutions below