Search SQL database in a text saved by TinyMCE

2

I'm using TinyMCE for text editing on my site. When I search for a word with an accent. Eg: análise , the query does not count because the bank is saved in HTML an&aacutelise . I'm using ASP.Net MVC with SQL Server.

    
asked by anonymous 17.08.2015 / 17:21

1 answer

2

There's not much information but basically what you need to do is treat HTML as a special form. You must decide whether to convert the HTML to a common text before you write it to the database or convert your search term to HTML encoding. You need to decide whether you want to write as HTML yourself or if the recording is in poor shape for you and you need to leave it in plain text.

Depending on what you need this will not solve everything but this is the basics you should do.

Utility methods to do this: WebUtility.HtmlEncode and WebUtility.HtmlDecode .

Following your code should look something like this:

listaNoticia = context.GBV_Noticia.Where(x => x.idPessoa == idPessoa &&
    x.dsConteudo.Contains(WebUtility.HtmlEncode(texto)) && x.icAtivo == "S" &&
    x.dtExclusao == null && x.dtPublicacao <= DateTime.Now &&
    (x.dtForaDoAr == null || x.dtForaDoAr >= DateTime.Now))
    .OrderBy(x =>x.dtPublicacao).ToList(); 
    
17.08.2015 / 18:06