AutoQuery endpoint that supports AND and OR filters

Is it possible to have 1 endpoint that supports both AND and OR expressions?

So for example, you could search for all Customers with First Name “John” or “Tom” AND Last Name “Smith” or “Jones”?

If you’re just doing an exact match you should be able to use the %In query conditions, e.g:

public string[] FirstNamesIn { get; set; }
public string[] LastNamesIn { get; set; }

Otherwise you can try using a custom [QueryDbField] properties like:

[QueryDbField(Template = "{Field} = {Value1} OR {Field} = {Value2}", 
            Field = "FirstName")]
public string[] FirstNames { get; set; }

[QueryDbField(Template = "{Field} = {Value1} OR {Field} = {Value2}", 
            Field = "LastName")]
public string[] LastNames { get; set; }

You can also use [QueryDbField(Term)] to change query behavior for how the property condition applied, but this only applies to a single property, i.e. not a group of related properties.

If these aren’t sufficient you’d need to create a Custom AutoQuery Implementation which applies custom conditions to the populated query, something like:

var q = AutoQuery.CreateQuery(query, base.Request, db);
q.And(x => x.FirstName == x.FirstName1 || x.FirstName == x.FirstName2);
q.And(x => x.LastName == x.LastName1 || x.LastName == x.LastName2);