Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.
Trevor Pilley edited this page Apr 7, 2017 · 55 revisions

Welcome to the Net.Http.WebApi.OData wiki!

NuGet version

Net.Http.WebApi.OData is a C# library which parses an OData query uri into an object model which can be used to query custom data sources which are not IQueryable.

Configuration

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        // Configure routes, etc

        // Build the OData Entity Data Model
        var entityDataModelBuilder = new EntityDataModelBuilder();
        entityDataModelBuilder.RegisterEntitySet<Category>("Categories");
        entityDataModelBuilder.RegisterEntitySet<Product>("Products");
        entityDataModelBuilder.BuildModel();
    }
}

Getting the OData Query Options

To use it in your own Web API, firstly install the nuget package Install-Package Net.Http.WebApi.OData and then in your controller, define a Get method which accepts a single parameter of ODataQueryOptions:

public IEnumerable<MyClass> Get(ODataQueryOptions queryOptions)
{
    // Implement query logic.
}
Clone this wiki locally