Using LIKE operator in LINQ to Entity -


Currently in our project we are using unit framework and LINQ. We want to create a search feature where the client fills different filters but they are not forced.

In order to query this "dynamic" in LINQ, we think of using the same operator, either to get the field or "%" everything if the user does not fill that field Could.

We are joking on when we found that it does not support the same way. After some searching, we read many answers where it is very expensive to use Starwith, but it is useless for us.

Is that the only solution such as:

  objectcity & lt; Contacts & gt; Contact = DB contact; If (Pattern! = "") {Contacts = contacts.Where ("This name is like @pattern"); contact. Parameter.Add (New ObjectPamator ("Pattern", Pattern);}  

However, we would love to be with linq only.

Happy coding!

Did you try to include it?

  contact.); See this link for a brief example of how LINQ generates  


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -