Skip to Main Content

Oracle Developer Tools for Visual Studio

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Entity Framework 6 Provider - Case Insensitive LINQ to SQL using String.Equals

Syd BSep 8 2015 — edited Sep 8 2015

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,


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 6 2015
Added on Sep 8 2015
0 comments
4,509 views