How to: Create a Data Service Using the Reflection Provider (WCF Data Services)

 

WCF Data Services enables you to define a data model that is based on arbitrary classes as long as those classes are exposed as objects that implement the IQueryable<T> interface. For more information, see Data Services Providers.

The following example defines a data model that includes Orders and Items. The entity container class OrderItemData has two public methods that return IQueryable<T> interfaces. These interfaces are the entity sets of the Orders and Items entity types. An Order can include multiple Items, so the Orders entity type has an Items navigation property that returns a collection of Items objects. The OrderItemData entity container class is the generic type of the DataService<T> class from which the OrderItems data service is derived.

System_CAPS_ICON_note.jpg Note

Because this example demonstrates an in-memory data provider and changes are not persisted outside of the current object instances, there is no benefit derived from implementing the IUpdatable interface. For an example that implements the IUpdatable interface, see How to: Create a Data Service Using a LINQ to SQL Data Source.

[!CODE [Astoria Reflection Provider#CustomIQueryable](../CodeSnippet/VS_Snippets_Misc/astoria reflection provider#customiqueryable)]

How to: Create a Data Service Using a LINQ to SQL Data Source
Data Services Providers
How to: Create a Data Service Using an ADO.NET Entity Framework Data Source

Show: