Is there a recommended way to search for each of several terms with StartsWith when the terms are not known at compile time?
I imagine something like this:
var searchTerms = "John Doe".Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var query = session.Query<Person, PersonIndex>() .Where(x => x.FirstName.StartsWithAnyOf(searchTerms) || x.LastName.StartsWithAnyOf(searchTerms));
The request will be equivalent to:
var query = session.Query<Person, PersonIndex>() .Where(x => x.FirstName.Starts(searchTerms[0]) || x.LastName.StartsWith(searchTerms[0]) || x.FirstName.Starts(searchTerms[1]) || x.LastName.StartsWith(searchTerms[1]));
Is the response to creating a LINQ query at runtime (PredicateBuilder or similar)?
kendaleiv
source share