How to use like in linq C #

0

I want to obtain a record of an existing article in the database, what I do is that in a textbox I capture the text. The fact is that with == works for some articles, but for many of these, it does not generate a null reference, I want to try like until now I have tried the following

var QueryArticulo = _db.articuloes.Where(s => s.nombre like "'%'+TextBoxArticulo.Text+'%'");

some form of how to incorporate it or what else can I use?

    
asked by Andrex_11 25.10.2018 в 21:49
source

2 answers

1

If what you want is to use a method as if it were a like, use the contais method that will return you according to the characters you pass, your code should be like this,

var QueryArticulo = _db.articuloes.Where(s => s.nombre.Contains(TextBoxArticulo.Text)).ToList();
    
answered by 25.10.2018 / 21:55
source
0

In this link you can find the answer at a detailed level of my question, I hope to help you

link

    
answered by 25.10.2018 в 22:08