Further below I provide a short review for my session and I also provide the PowerPoint presentation along with the DB scripts and source code (C#) of my demos.
The problem domainMany applications, and especially web applications, face a set of problems in today’s environments. For example, it is difficult to identify the different types of clients and users accessing these web applications. Each different client has its own particularities which make it difficult, if not impossible, for web applications to perfectly work with all these types of clients. This requires different web methods for each client, different paging and filtering techniques and so on.
Furthermore, during the last few years, the wide usage of the Internet enabled the massive spreading of Web Applications. To this end, a new form of web applications has emerged; the well known “Connected” applications. This new type of web applications includes Rich AJAX web applications, Flash & Silverlight applications, Mashups, etc. These applications need continuous feeding of data in dedicated data channels in order to be fast and efficient. They somehow require a separation of the data and presentation layers.
The old approachThe traditional way for enabling web applications to efficiently work with the different types of clients was to include additional logic in their code in order to cover most of the different scenarios. Though, this is not anymore an efficient way for handling the uniformity of clients which access these applications as the different types of clients are highly increased.
How about using a framework that helps you develop and access data services in a uniform way?
Such case could be really interesting…
Introducing the Microsoft ADO .NET Data Services FrameworkThe ADO.NET Data Services framework consists of a combination of patterns and libraries which enable the creation and consumption of data services for the web. Using the framework, it is easy to create flexible data services that are naturally integrated with the web and maintain the REST style. To this end, URIs are used to point to pieces of data and well-known formats such as JSON and XML are used for representing that data.
Interacting with your data is now uniform and easy as by using the HTTP verbs GET, PUT, POST and DELETE, you can perform any operation you like on your data.
The mappings between the above HTTP verbs and the SQL language are:
If you use the web, and specifically HTTP to provide and consume your data, you will find ADO.NET Data Services very interesting as by utilizing the enormous amounts of infrastructure that already exists to support HTTP due to the wide spreading of the Internet, you are able to easily build flexible and powerful data services fully supporting “Connected” applications which is nowadays the trend in web applications design.
The following figure illustrates the different types of clients that access data through HTTP:
Why Use the ADO .NET Data Services Framework?The answer to this question is quite simple; as “Connected” applications (Rich AJAX web applications, Flash & Silverlight applications, Mashups, etc.) are the trending type of web applications, they need the corresponding data services in order to feed them with data, without affecting their presentation layer. ADO .NET Data Services allows these applications to have a dedicated data channel which allows it to be fed with data by an ADO .NET Data Service. Usually the only line of sight from these applications, is HTTP, so using the framework makes things really simple.
With this technology, the data is moved out-of-band with the presentation and behavior information thus allowing the web application on the one hand not have any delays on the presentation layer, and on the other hand to have continuous access to its data source.
The architecture of an ADO .NET Data ServiceThe following figure illustrates the architecture of a data service:
At the very bottom of this architecture there are the relational and non-relational sources.
Next there is the ADO .NET Entity Framework which is used for handling the relational sources and a custom LINQ provider for handling the non-relational sources. The Data Services Runtime exists as a DLL. Next, there is the Hosting/HTTP Listener for which the out of the box implantation is WCF hosted within an ASP .NET web page (though, you can author your own listener if you like). On the very top of this architecture, there is the HTTP stack, against which you can issue HTTP commands (using the abovementioned HTTP verbs) in order to access and process your data.
Consuming a Data ServiceThe following figure illustrates the various ways available for consuming a data service implemented within the ADO .NET Data Services framework:
As you can see, actually an HTTP stack is enough! Of course, if you like to access your data service using higher levels of abstractions you can use JSON & AtomPub clients and even easier; Windows Data Services Clients such as .NET Framework, Silverlight 2 or 3, AJAX, and so on.
Securing a Data ServiceThere are several ways available for securing a Data Service within the ADO .NET Data Services Framework.
With respect to Visibility, you can use:
- Per-container visibility control
- Read, Query and Write options
With respect to Authentication you can use:
- Integration with hosting environment
- ASP.NET, WCF or custom authentication schemes
With respect to Interceptors you can use:
- Execution before HTTP GET/PUT/POST/DELETE
- Enabling of validation and custom row-level security policies in order to maintain the REST style
With respect to Service Operators you can use:
- Custom entry points, e.g. /MyTags?startDate=’2009-09-02′
- Composable, follow URI scheme
PowerPoint PresentationPlease find below my PowerPoint presentation for this session.
Source Code for DemosPlease find below the source code for my demos.
* For all the demos, you will have to modify the connection string in the Web.config file, connection string entry in order to point to your SQL Server 2008 instance. To this end, please replace “.sql2008” with your SQL Server 2008 instance name. Also I used Windows Authentication (trusted connection) for connecting to the SQL Server Instance.
Download link for source database.
Demo 1: Examining an ADO .NET Data ServiceSummary: In this demo, we examine a pre-built data service and see how we can interact with it using a Web Browser and an HTTP debugging tool.
Download link for demo 1 (and 2) source code.
Demo 2: Building a Data Service from ScratchSummary: In this demo I build a data service from scratch using Visual Studio 2008 SP1.
Procedure: There is not sample code for this demo, as by completing the demo, you end up to a source code identical to the source code of demo 1.
Demo 3: Consuming a Data ServiceSummary: In this demo, in addition to the data service which was build during demo 2, I also create a .NET client (Windows Console Application in C#) within the same project for consuming the service using LINQ to Data Services (this is actually LINQ to Entities).
Download link for demo 3 source code.
* Disclaimer: The source code for the demos is intended to be used only for demo purposes. Do not use it for Production systems as it is simplified for demo purposes.
SummarySumming up this review, I would like to say that using ADO.NET Data Services makes it really easy to expose your data over HTTP and thus build powerful and flexible data services.
Using URIs (entities and associations –> resources and links), HTTP Verbs for data manipulation, and the well-known and simple formats JSON and AtomPub for data representation makes it easy to build RESTful data services with all the benefits derived by using the REST style.
ADO .NET Data Services are very useful for developing AJAX & Silverlight Applications, Online Data Services, Mashups and much more.
Of course, I could not end this review without mentioning the Cloud. Many of the Microsoft cloud services expose data using the same REST conventions as used by ADO .NET Data Services. This enables using the ADO .NET Data Services Framework not only for on premises services, but also with services hosted on the cloud!
This session’s topic falls under one of my favorite Microsoft Technologies; ADO .NET – Data Access! I plan to deliver even more webcasts in the future, again dedicated to ADO .NET.
I would like to thank PASS for inviting me to actively participate to this great SQL Server event and congratulate all the people who made this event a smashing success!
Drop me a line if you have any comments!