Build a RESTful service with OData Congyong Su Senior Software Engineering Manager Microsoft
Why RESTful service? API leverages the semantics of HTTP Verbs: Post, Get, Put/Patch, Delete Methods: Create, Read, Update, Delete Uri: Resource hierarchy Status: 200 OK, 404 Not Found Content: application/json API integration to web Foundation piece for dynamic web – for example, the MVVM pattern Reach Desktop, phone, device, etc.
Why OData service? Consistency Conventions Rich query REST is an architectural style Conventions API path inferred POST ~/Customers GET ~/Customers GET ~/Customers/{id} PATCH ~/Customers/{id} DELETE ~/Customers/{id} Rich query filter, select, expand, orderby, top, skip, count
How to build an OData service OData Web API If you are familiar to Model-View-Controller: MVC Start from small Low-level control RESTier If you used and miss WCF Data Services Focus on business logic
Standard Solution: OData v4 Web API Model builder ODataConventionModelBuilder Routing MapODataServiceRoute Controller ODataController Query EnableQueryAttribute
Demo: OData v4 Web API
Why RESTier? Web API is easy, but require a controller per entity set ODataLib is powerful, but with low-level APIs Zero controller is possible Focus on business logic
What is RESTier? A turnkey solution to build RESTful API services Builds upon OData v4 Web API and ODataLib
Demo: RESTier
Summary OData v4 Web API is easy to start with RESTier is another layer of abstraction on top of OData Web API
Questions?