It appears that the Entity Framework 6 Provider does not take into account case insensitivity using string,Equals specifying a StringComparison of "IgnoreCase" type. When inspecting the SQL that gets generated by the LINQ statement an LINQ query such as the following:
DbContext.Entities.Where(x=>x.SomeString.Equals(value,StringComparison.OrdinalIgnoreCase));
Generates a SQL statement where the SomeString column and the parameter passed in are not changed to upper or lower case :
WHERE (("Extent1"."SOMESTRING" = :p__linq__0) OR (("Extent1"."SOMESTRING" IS NULL) AND (:p__linq__0 IS NULL)))
The only workaround I can find is to explicitly convert the value in the linq query to upper or lower:
DbContext.Entities.Where(x=>x.SomeString,ToLower() == value.ToLower());
The previous example generates the following where constraint:
WHERE (((LOWER("Extent1"."QUICKLOOKID")) = (LOWER(:p__linq__0))) OR ((LOWER("Extent1"."QUICKLOOKID") IS NULL) AND (LOWER(:p__linq__0) IS NULL)))
My Question is whether this behavior is by design or maybe it was missed. It is my belief that string comparison using String.Equals or String.Compare is a much better approach than forcing an equality check on too strings using the == operator.
Thanks,