So I have this linq query clause.
var ctx = new Context();
IQueryable<Users> consulta = ctx.Users;
if ( filters.Count > 0 )
query = query.Where( p => filters.Contains(p.Name) ||
filters.Contains(p.LastName) );
Filters
Is an string list that contains unordered names and lastnames (not necessary complete). For example: Filter {Mary, Joseph Ken} but DB {Mary Katie, Joseph Kendall}.
Expected results
For the previous filters I want the query to return the list of users no matter if within the filters its names and lastnames are incomplete but correct. So if the filter has “Mary” it must found the db record with “Mary Katie” and so on.
You can use mix of
String.ContainsandAnyto solve your problem in linq2entity without fetching extra data from DB: