Solved

ACCENT insensitive comparison

Posted on 2008-10-16
4
2,544 Views
Last Modified: 2013-12-17
need to modify this function so it will be ACCENT insensitive. My server (Sql2008) is set with the correct collation, so if i query directly against the database the result is OK. But i query from a preloaded list (to speed up things).

 How can this be achived?

Here is the C# function:

        internal IEnumerable<BO.DriverSearchGridBO> ApplySearchTextFilterTogrid IEnumerable<BO.DriverSearchGridBO> list, string textToSearch)
        {
            IEnumerable<BO.DriverSearchGridBO> newlist =
                  from d in list
                  where d.Name.Contains(textToSearch)
                  select d;
            return newlist;
        }

Thanks,
0
Comment
Question by:Morris7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 22731588
you can try with:

IEnumerable<BO.DriverSearchGridBO> newlist =
                  from d in list
                  where d.Name.IndexOf(textToSearch, StringComparer.InvariantCultureIgnoreCase) >= 0
                  select d;
            return newlist;
0
 

Author Comment

by:Morris7
ID: 22731799
To make it  compile i had to use
StringComparison instead of StringComparer...

But the result is the same: Does not work for ACCENT insensitive.

If i search for E i need to find E,É,Ë,È etc.
0
 
LVL 27

Accepted Solution

by:
ddrudik earned 500 total points
ID: 22737508
This is a feature request for the .NET framework, currently the way to do this with regex would be to put the target characters into a character set and search with that, such as:

if(System.Text.RegularExpressions.Regex.IsMatch("testËtest", "[EÉËÈ]")){
  //do something
}

possibly:
where System.Text.RegularExpressions.Regex.IsMatch(d.Name, "[EÉËÈ]")
0
 

Author Closing Comment

by:Morris7
ID: 31506756
Solution not tested...but it may be a valid starting point.
For now i added an extra field with accent removed that is used as the search field
0

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question