Fernando Juarez Fernando Juarez - 8 months ago 53
C# Question

Servicestack - OR operator for consuming autoquery rdbms API

Is there a way to use OR operator for conditions in queries. I know that the modifier

can be used but this will change the behavior of the property always. Maybe some times I need to query with AND and some times I need to query with OR, with the same field.
Something like

state = la AND amount = 1000 OR totalamount=1000



Answer Source

You can't specify an OR condition on the QueryString adhoc like this but you could potentially use a custom template to create a custom query, e.g:

public class Query : QueryDb<Table>
    public int Amount { get; set; }
    public int TotalAmount { get; set; }

    [QueryDbField(Template = "Amount = {Value} OR TotalAmount = {Value}")]
    public int AnyAmount { get; set; }

Which should let you then query with: