c# - Entity Framework Filtering with a List of String -


i want filter results according list of strings, this:

list<string> filters = {"a", "b", "c", "d"}; var results = (from r in db.entries                 r.word.startswith(filters[0])                ||r.word.startswith(filters[1])                ||r.word.startswith(filters[2])                ||... 

i don't know length of filters list how query dynamically in linq?

thanks in advance.

this works little bit different in linq, kind of other way around

use .contains()

something this:

from r in db.entries filters.contains (r.word.substring(0,1)) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -