Tuesday, January 20, 2015

Restier: Bringing WCF Data Services and Web API OData together

Microsoft is working on a new framework called Restier:

RESTier is a RESTful API development framework for building standardized, OData V4 based REST services on .NET. It can be seen as a middle-ware on top of Web API OData. RESTier combines the convenience and simplicity of WCF Data Services alongside the flexibility and extensibility of Web API OData.

Similar to a WCF Data Service it exposes your Data Model through a REST service. 

Get started.
  • Create a new MVC application
  • Add an Entity Framework Code First context
  • Include the Microsoft.Restier NuGet Package(don’t forget to set Include prerelease)

image

  • Create a Domain class that wraps your DbContext:
  • Add a Web Api controller inheriting from ODataDomainController that wraps the Domain class:
  • As a last step add an extra route to the WebApiConfig file:
  • If you run the application and browse to /api/northwind, you can see the available entity sets:

image

No comments: