Compartilhar via


Expose Your Data as a Service (WCF Data Services)

Important

WCF Data Services has been deprecated and will no longer be available for download from the Microsoft Download Center. WCF Data Services supported earlier versions of the Microsoft OData (V1-V3) protocol only and has not been under active development. OData V1-V3 has been superseded by OData V4, which is an industry standard published by OASIS and ratified by ISO. OData V4 is supported through the OData V4 compliant core libraries available at Microsoft.OData.Core. Support documentation is available at OData.Net, and the OData V4 service libraries are available at Microsoft.AspNetCore.OData.

RESTier is the successor to WCF Data Services. RESTier helps you bootstrap a standardized, queryable, HTTP-based REST interface in minutes. Like WCF Data Services before it, Restier provides simple and straightforward ways to shape queries and intercept submissions before and after they hit the database. And like Web API + OData, you still have the flexibility to add your own custom queries and actions with techniques you're already familiar with.

WCF Data Services integrates with Visual Studio to enable you to more easily define services to expose your data as Open Data Protocol (OData) feeds. Creating a data service that exposes an OData feed involves the following basic steps:

  1. Define the data model. WCF Data Services natively supports data models that are based on the ADO.NET Entity Framework. For more information, see How to: Create a Data Service Using an ADO.NET Entity Framework Data Source.

    WCF Data Services also supports data models that are based on common language runtime (CLR) objects that return an instance of the IQueryable<T> interface. This enables you to deploy data services that are based on lists, arrays, and collections in the .NET Framework. To enable create, update, and delete operations over these data structures, you must also implement the IUpdatable interface. For more information, see How to: Create a Data Service Using the Reflection Provider.

    For more advanced scenarios, WCF Data Services includes a set of providers that enable you to define a data model based on late-bound data types. For more information, see Custom Data Service Providers.

  2. Create the data service. The most basic data service exposes a class that inherits from the DataService<T> class, with a type T that is the namespace-qualified name of the entity container. For more information, see Defining WCF Data Services.

  3. Configure the data service. By default, WCF Data Services disables access to resources that are exposed by an entity container. The DataServiceConfiguration interface enables you to configure access to resources and service operations, specify the supported version of OData, and to define other service-wide behaviors, such as batching behaviors or the maximum number of entities that can be returned in a single response. For more information, see Configuring the Data Service.

For an example of how to create a simple data service that is based on the Northwind sample database, see Quickstart.

See also