Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework and Case Insensitive String Search

I have a Entity Framework entity with a string Property named Description.
Searching for all entities where the Description contains a string is as simple as:

var res = from u ctx.Users where u.Description.contains(str) select u;

But suppose I want to support case insensitive search?

like image 464
sternr Avatar asked Sep 14 '11 11:09

sternr


People also ask

How do you make a search case-insensitive?

Case insensitive SQL SELECT: Use upper or lower functions or this: select * from users where lower(first_name) = 'fred'; As you can see, the pattern is to make the field you're searching into uppercase or lowercase, and then make your search string also be uppercase or lowercase to match the SQL function you've used.

Is EF core case-sensitive?

For one thing, EF Core does know not which case-sensitive or case-insensitive collation should be used. More importantly, applying a collation would in most cases prevent index usage, significantly impacting performance for a very basic and commonly-used . NET construct.

How do you make a SQL query case-insensitive?

To do a case-insensitive comparison, use the ILIKE keyword; e.g., column ILIKE 'aBc' and column ILIKE 'ABC' both return TRUE for 'abc' . In contrast, MySQL and MS SQL Server have case-insensitive behaviors by default. This means WHERE column = 'abc' returns TRUE for e.g., 'abc' , 'ABC' , or 'aBc' .

What is case-insensitive search in SQL?

SQL keywords are by default set to case insensitive that means that the keywords are allowed to be used in lower or upper case. The names of the tables and columns specification are set to case insensitive on the SQL database server, however, it can be enabled and disabled by configuring the settings in SQL.


1 Answers

If you're using Linq to enties the search is done by the sql server so if the search is case sensitive or not depends on server settings.

like image 149
Piotr Auguscik Avatar answered Sep 28 '22 00:09

Piotr Auguscik