Make Entity Framework Case Insensitive

Is it possible to set the suffix framework string comparison register by default?

If i use

string.StartsWith("stringToCompare", StringComparison.CurrentCultureIgnoreCase)

it works. But when do I need to use

string.Contains("strigToCompare")

he has no overload.

+5
source share
1 answer

You can simply change the case of both fields to uppercase:

String stringToCompare = "Some String";

string.ToUpper().Contains(stringToCompare.ToUpper())

This will make the case insensitive, converting the entire case to uppercase. Of course, ToLower () will also work.

+3
source

All Articles