How to return independent accentuation search on Asp.Net MVC systems

Asked

Viewed 143 times

3

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

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 a lot of data. I am using the methodology 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 for the above code ignore the accent along with Toupper high box()

  • You haven’t said what that system is or how or where this research is done or what kind of research this is. You just told us what the DBMS is and what your libraries are, but you didn’t say anything about your tables, columns and procedures SELECT. So I can’t tell you how you ignore the accent because you can’t even tell where or how you would put it. Edit your question and add that kind of information.

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 wish to consult with:

var result = from p in People
             where p.Name.ToUpper().Contains(RemoveDiacritics(filter.ToUpper()))
             select p;
  • You are absolutely right I just edited, my question @Migueljm and Victor Stafusa would give you to assist me in Linq SQL which I posted in my edited question

  • Where(x => x.Cidade.Contains(city) &&&&##Xa;var search(x.nome.Contains(company) || x.CategoriaEmpresa.Any(c => c.Categoria.Name.Contains(company))) . Tolist();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.