Introducing ADO.NET Data Services
page 4 of 5
by Sergey Zwezdin
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 25751/ 45

Data sources

As it has been mentioned above, a data source for a web service is an objective model of a data serves. When a web-service handles a client request it works with data provided by this model.

By default, as a data source model, ADO.NET Entity Framework or LINQ to SQL is used. These platforms allow us to give access to relational data without any additional efforts. The only thing you should do to use this model is to specify it in generic-parameter when you organize inheritance from a general base class.

However, there are case when it is impossible to use these approaches. In practice, sometimes you need to use another type of OR/M platform or to give access to nonrelational data. In this case ADO.NET Data Services architecture is very flexible.

To create your own data source you should build a simple class. There is no need to inherit it from standard classes or implement some interfaces in it. This class should contain public properties which return objects of type IQueryable<>. This condition is enough to make the model readable.

An entity passed through web service should have a key field. This key field is defined automatically if there is "ID" or "EntityTypeID" name ("EntityType" is a name of an entity). If a name of a key field differs from the given scheme, it is necessary to mark entity with DataServiceKey attribute where you need to specify a name of a key field in its container.

Listing 5 - The key field defining

public class Data
      public int ID { get; set; }
      public string Name { get; set; }

The described approach allows us to create only readable data models. In order to be able to modify data in a model, it is necessary to implement the interface IUpdatable. As a part of this interface there are descriptions of methods that allow us to apply changes.

View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2023  |  Page Processed at 2023-10-01 1:22:58 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search