Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ACCENT insensitive comparison

Posted on 2008-10-16
4
Medium Priority
?
2,550 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 1500 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

What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
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 …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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