Solved

ACCENT insensitive comparison

Posted on 2008-10-16
4
2,504 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now