Co-Sponsored by: Media Sponsors:
Slot # 18 - Building Flexible Data Services for the Web
Using the ADO .NET Data Services Framework
17:00 GMT (UTC)
Artemakis ArtemiouB.Sc., M.Sc., Microsoft SQL Server MVP, MCP, MCTS
Cyprus .NET User Group (CDNUG) Lead
INETA-Europe Country Leader (CY)
H.S.Data Ltd.
Agenda
• Data Access
• The ADO .NET Entity Framework
• The ADO .NET Data Services Framework
• Why ADO .NET Data Services?
• The Architecture of a Data Service
• Building a Data Service From Scratch
• Consuming a Data Service
• Data Services Security
• Summary
Data Access
Definition
• A way of accessing a data repository for storing, retrieving, or manipulating
data
Standards Used for Data Access
• SQL, ODBC, JDBC, ADO.NET, XML, XQuery, Xpath, Web Services
ADO .NET
• Part of the base class library that is included with the Microsoft .NET
Framework
• Access and modify data stored in relational database systems
• Access and modify data in non-relational sources
• Provides developers with fast and robust data access methods
The ADO .NET Entity Framework (I)
Entity Data Model
• Describes conceptual schema
• An object model, independent of storage considerations
• Entities and their relationships are modeled by using two basic types:
– EntityType & AssociationType
Mapping Model
• Conceptual schema to database storage
• Mapping model implemented via three XML files
– Each has its own XSD vocabulary
– Conceptual schema (CSDL)
– Storage schema (SSDL)
– Mapping schema (MSL)
The ADO .NET Entity Framework (II)
Benefits
• Abstraction in Data Access
– Just know and use the conceptual schema
– If relational database changes, not need to change the code
• Simplified representation of Relational Models
Entity Framework and ADO .NET Data Services
• Conceptual model drives the service tier
• Service tier adjusts automatically upon updates to the conceptual model
• Uniformity among the service code
• Code reuse
The ADO .NET Data Services Framework (I)
WWW - HTTP
Desktop
& Web
Apps
Mobile &
Smart
ClientsDifferent
Types of
Users
Media
Centers
Your
Data
The ADO .NET Data Services Framework (II)
REST Interface
• Data is communicated/handled in the style of representational state transfer
(REST)
– CRUD operations are performed using HTTP Verbs:
• GET = SELECT
• POST = INSERT
• PUT = UPDATE
• DELETE = DELETE
– Resources are identified by URIs (entities and associations resources and links)
– Formats: JSON, AtomPub
Tightly Integrated with HTTP
• HTTP is often the only line of sight from an AJAX or Silverlight application
• Enormous amounts of infrastructure exists to support HTTP
Why ADO .NET Data Services?
Industry Trends
• “Connected” applications
– Rich AJAX web applications
– Flash & Silverlight applications, Mashups, etc.
Services Supporting “Connected” Applications
• Operation Center Services (example: Windows Live ID)
– More about process
• Data Centric Services (example: Windows Live Photos)
– Very popular
– Is all about data
– Enables the creation of AJAX & Silverlight apps, Mashups, etc.
Why ADO .NET Data Services?
MashupsSilverlight ApplicationsAJAX Applications
Data
HTML + Javascript
Data Feeds
The data is moved
out-of-band with the
presentation and
behavior information
Data
DLL + XAML
Traditional Tiered
Web Applications
The data is conveyed along
with presentation and
behavior information
Data
& Other
Information
The Architecture of a Data Service
HTTP
Data Services Runtime
Hosting/HTTP Listener
Relational
SourceNon-Relational
Source
Data Access Layer
Entity
Framework
Custom LINQ
provider
IQueryable [+ IUpdatable]
• Out of the box: WCF hosted within an ASP.NET
web page
• You can also author your own host
• The ADO.NET Data Services framework exists
as a DLL
Two paths:
• Relational data – Entity Framework
• Everything else - Language Integrated Query (LINQ)
DEMO:
Examining an ADO .NET Data Service
Building a Data Service from Scratch
Development Environment
• Visual Studio 2008 SP1
• .NET Framework 3.5 SP1
Data Sources
• Entity Framework for Relational Data
• LINQ for Non-Relational Data
Model-Driven
• Structural description in Entity Data Model
• Schema shapes the service contract
DEMO:
Building a Data Service from Scratch
Consuming a Data Service
An HTTP Stack is Enough!
JSON & AtomPub clients
Windows Data Services Clients
• .NET Framework
– LINQ to ADO.NET Data Services
• Silverlight 2
• AJAX (currently on codeplex)
• ASP.NET Data Source control
Level of
abstraction
Lowest
Highest
DEMO:
Consuming a Data Service
Data Services Security (I)
Visibility
• Per-container visibility control
• Read, Query and Write options
Authentication
• Integrate with hosting environment
• ASP.NET, WCF or custom authentication schemes
Data Services Security (II)
Interceptors
• Execute before HTTP GET/PUT/POST/DELETE
• Enable validation, custom row-level security policies
• Maintain the REST interface
Service Operators
• Custom entry points, e.g. /MyTags?startDate='2009-09-02'
• Composable, follow URI scheme
Summary
Data is exposed over HTTP via ADO.NET Data Services
• Entity Data Model
• URIs (entities and associations resources and links)
• HTTP Verbs for data manipulation
– GET = SELECT
– POST = INSERT
– PUT = UPDATE
– DELETE = DELETE
• Formats: JSON, AtomPub
ADO .NET Data Services Very Useful for:
• AJAX & Silverlight Applications, Online Data Services, Mashups & the Cloud!
Resources
• ADO.NET Data Services Framework Website
• http://astoria.mslivelabs.com/Default.aspx
• ADO.NET Data Services Team Blog
• http://blogs.msdn.com/astoriateam
• Representational State Transfer (REST)
• http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
• The Atom Publishing Protocol RFC
• http://tools.ietf.org/html/rfc5023
• JavaScript Object Notation RFC (JSON)
• http://tools.ietf.org/html/rfc4627
• Artemakis Artemiou’s Blog
• http://aartemiou.blogspot.com
Q & A
Contact PASS
203 North LaSalle - Suite 2100
Chicago, IL 60601
Tel 1.604.899.6009
Fax 1.604.899.1269
www.sqlpass.org
November 2-5. Seattle WA.
The Premier Conference for SQL Server Professionals
Register Today. www.summit2009.sqlpass.org
Co-Sponsored by: Media Sponsors:
Thank you for attending
24 Hours of PASS