Solved

ACCENT insensitive comparison

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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