ninjanye / SearchExtensions

Library of IQueryable extension methods to perform searching
MIT License
331 stars 52 forks source link

Search does not handle some special characters #47

Open spicamelot opened 2 years ago

spicamelot commented 2 years ago

Hello,

I am filtering a list of users by using a search pattern and NinjaNye.SearchExtensions 3.0.1. One of the user has a special character within its name ( the literal Æ ) The search returns all expected results but the user with the special character.

Here is my code :

string pattern = "";

var coaches = context.Coaches.Search(t => t.UserName.ToLower())
                                                .Containing(pattern.ToLower())
                                                .OrderBy(c => c.UserName);

// a row is missing in the coaches variable.
Crusader2010 commented 1 year ago

What's the point of searching for an empty string? Why not just return the whole list of users? Also, does your database collation properly handle special (unicode) characters? Is it set to be case sensitive or not (if not, you don't need the .ToLower() )?

Try the query directly from SQL and see if you get that user's name. Here are some hints or things you can use: https://stackoverflow.com/questions/4251765/how-to-use-like-statement-with-unicode-strings