Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ACCENT insensitive comparison

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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

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…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

971 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