How to return search regardless of accent on Asp.Net MVC systems [closed]

3

I have a problem with a system in relation to the search that does not return a result for reasons of emphasis.

I would like to know how to make the accent be ignored in the system?

Note The system is already hosted and running with SQL Server database containing lots of data. I'm using Code First, Asp.Net MVC, Entity Frameworks

The SQL Link I'm using is this.

var pesquisa = db.Empresa.Where(x => x.Cidade.Contains(cidade) &&
                                (x.Nome.Contains(empresa)
                                || x.CategoriaEmpresa.Any(c => c.Categoria.Nome.Contains(empresa))))
                                .ToList();

How do I get the above code to ignore the accent along with upper box ToUpper ()

    
asked by anonymous 29.10.2017 / 22:09

1 answer

1

If you use direct queries in sql:

Select * from tabela where campo like '%texto_om_acento%' collate Latin1_General_CI_AI

If you want to consult with linq:

var result = from p in People
             where p.Name.ToUpper().Contains(RemoveDiacritics(filter.ToUpper()))
             select p;
    
30.10.2017 / 13:12