Search code examples
restasp.net-web-apiodataasp.net-web-api-odata

OData Query: Getting several rows based on a column criteria


I have a table that holds an attribute field and its corresponding value. For an instance several attributes are applicable, and I would like to return a specific set of attributes for this instance.

    |Attribute|Value|
    ----------
    | A       | 1   |
    ----------
    | B       | 2   |
    ----------
    | C       | 3   |
    ----------

How can I query with Odata to get attribute A and C and their corresponding values?

As of now I'm only able to get a single row with $filter=endswith(Attribute, 'A').


Solution

  • You can simply add more filters with or operator on ODATA query, something like this:

    $filter=(endswith(Attribute, 'A') or endswith(Attribute, 'C'))