Answer the question
In order to leave comments, you need to log in
How would you implement filtering on multiple fields in Entity Framework?
There is a filter like this:
return DbSet.Where(u => u.FirstName.IndexOf(search) > -1
|| u.LastName.IndexOf(search) > -1
|| u.UserName.IndexOf(search) > -1
|| u.Email.IndexOf(search) > -1);
return DbSet.Where(u => u.FirstName.IndexOf("WORDS ARRAY")) > -1
|| u.LastName.IndexOf("WORDS ARRAY") > -1
|| u.UserName.IndexOf("WORDS ARRAY") > -1
|| u.Email.IndexOf("WORDS ARRAY") > -1);
Answer the question
In order to leave comments, you need to log in
For array search - Array.IndexOf . I won’t say for sure if it will work in LINQ , I wouldn’t do it myself with data from the database. SQL is our everything :)
string[] arr = {"слово 1", "слово 2"};
return DbSet.Where(u => Array.IndexOf(arr, u.FirstName) != -1);
string[] arr = {"слово 1", "слово 2"};
return DbSet.Where(u => arr.Any(itm=> itm == u.FirstName));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question