Since Web API OData V5.5, it supports filter, select and orderby on dynamic properties.

Let’s see a sample about this feature.

CLR Model

First of all, we create the following CLR classes as our model:

public class SimpleOpenCustomer
    public int CustomerId { get; set; }
    public string Name { get; set; }
    public string Website { get; set; }
    public IDictionary<string, object> CustomerProperties { get; set; }

Build Edm Model

Now, we can build the Edm Model as:

private static IEdmModel GetEdmModel()
    ODataModelBuilder builder = new ODataConventionModelBuilder();
    return builder.GetEdmModel();

Use filter, orferby, select on dynamic property


In the SimpleOpenCustomersController, add the following method:

public IQueryable<SimpleOpenCustomer> Get()
    return CreateCustomers().AsQueryable();

Request Samples

We can query like:

~/odata/SimpleOpenCustomers?$orderby=Token desc&$filter=Token ne null