大概五个月前,我们需要将框架里的重要组件通过RESTful API的形式暴露出来,当时我们进行了技术选型,在.Net平台 下,毋庸置疑,我们选择了Asp.Net Web API。不过在实现的过程中,我们又进行了筛选,一种说法是使用原生的Web API框架,另一种说法是使用Web API OData Framework(会多出学习成本)。最终我们决定还是使用原生的Web API框架。不过后来,由于对OData比较感兴趣,私下里我又对其进行了一些了解。在这里,我将官方的一些目录贴出来,供备案。
Getting started
OData is an OASIS standard for creating and consuming RESTful APIs. The OData .NET libraries help users to build and consume OData v4 services.
To build an OData V4 service, start by following:
- “Build an OData v4 Service with RESTier Library” for a turn-key experience, or if you are a data developer.
- “Build an OData v4 Service with OData WebApi Library” if you get used to MVC pattern, or you are a web developer.
To build an OData V4 client application to consume OData v4 Service, start by following:
- “Using OData Client Code Generator to generate client-side proxy class”
- “Using OData Connected Service to generate client-side proxy class”
- “Basic CRUD Operations with OData .Net Client”
Introduction
Libraries
- Core libraries
- ODataLib, namespace
Microsoft.OData.Core
. It contains classes to serialize, deserialize and validate OData JSON payloads (source code | binary | tutorial). - EdmLib, namespace
Microsoft.OData.Edm
. It contains classes to represent, construct, parse, serialize and validate entity data models (source code | binary | tutorial). - Microsoft.Spatial, namespace
Microsoft.Spatial
. It contains classes and methods that facilitate geography and geometry spatial operations (source code | binary | tutorial).
- ODataLib, namespace
- Web API OData, namespace
System.Web.OData
. It contains everything you need to create OData v4.0 endpoints using ASP.NET Web API and to support OData query syntax for your web APIs (source code | binary | tutorial). - RESTier, namespace
Microsoft.Restier
. RESTier is a RESTful API development framework for building standardized, OData V4 based RESTful services on .NET platform. It can be seen as a middle-ware on top of Web API OData. RESTier provides facilities to bootstrap an OData service like what WCF Data Services (which is sunset) does, beside this, it supports to add business logic in several simple steps, has flexibily and easy customization like what Web API OData do. It also supports to add additional publishers to support other protocols and additional providers to support other data sources. It is currently a preview version (source code | binary | tutorial). - OData Client for .NET, namespace
Microsoft.OData.Client
. It contains LINQ-enabled client APIs for issuing OData queries and consuming OData JSON payloads (source code | binary | tutorial).
Tooling
- OData Client Code Generator. An item template that simplifies the process of accessing OData v4 services by generating C# and VB.Net client-side proxy classes. It works with Visual Studio 2010, 2012, 2013 and 2015. (download | tutorial).
- OData Connected Service. An item template that simplifies the process of accessing OData v3 and v4 services by generating C# client-side proxy classes. It works with Visual Studio 2015 only. (download | tutorial).
Relationship