ADO.NET Data Services Mike Taulty Developer & Platform Group Microsoft Ltd [email_address]   http://www.miketaulty.com
Agenda The core bits that we’ll demo Overview of ADO.NET Data Services Exposing data sources Building clients Intercepting the server-side dispatch process The extra bits that we’ll talk about Dealing with batched operations Dealing with concurrency
Data Services – Overview Provides new functionality CRUD access to  data  over  RESTful  web services Built-in  URI-based query  syntax Client-side libraries for  .NET ,  AJAX  and  Silverlight Builds on top of WCF V3.5 Status In  VS 2008 Service Pack 1 , Ships Summer 2008 Current version is in Sp1 Beta 1 but has been through various previews
RESTful Web Services? Resources Res 1 Res 2 Res 3 Res 4 HTTP Request URL VERB Payload HTTP Response Status GET POST PUT DELETE XML JSON Payload XML JSON
RESTful? RE presentational  S tate  T ransfer Server-side resources identified by a URI Access is over HTTP, verb tied to action GET   to read the value of a resource POST   to create a new resource PUT  to update an existing resource DELETE   to delete a resource Returned data is “plain” – XML or JSON Is this “the death of SOAP”?
Data? What Kind of Data? Provide a type with public properties which are  IQueryable<T> Some rules about how  T  has to be formed Remember the extension method  AsQueryable() Only get write access if your type implements  IUpdatable Works well with generated code from; ADO.NET Entity Framework ( ObjectContext ) LINQ to SQL ( DataContext *)
Exposing Data
ADO.NET Entity Framework ? SQL Provider Oracle Provider ... Entity Provider Conceptual Model Store Model Map ADO.NET API ORM API
Using Entity Framework Data
Querying with Data Services URI based query mechanism http://myservice.svc/MyEntitySet Supports the notion of navigating by primary key MyEntitySet ( MyPrimaryKeyCol1, Col2, ... ) Supports various operators $orderby, $top, $skip, $expand, $filter, $value
Operators for $filter
Querying with the URI
Building Clients Services offer metadata MyService.svc/$metadata .NET clients made easier through a proxy generation tool datasvcutil.exe Useful for both regular .NET clients & Silverlight AJAX clients made easier through a script library “ Data Service AJAX Client Library” Available as a download on  Codeplex
Building Clients
Interception & Operations Possible to hook code into the framework For queries we can write Query interceptors For modifications we can write Change interceptors Can also expose custom functionality Service Operations Useful for providing “canned” functionality, can be parameterised
Interception, Operations
Batching of Operations “ INSERT” Customer 1 POST Order 1 POST Order 2 POST Order N POST
Batching of Operations “ INSERT” Customer 1 Order 1 Order 2 Order N POST
Batching of Operations Provides a mechanism to process  a batch 0 or more Query operations 0 or more [Create/Update/Delete] operations Uses multipart/mixed MIME type sent to a $batch endpoint Use SaveChanges(SaveChangesOptions.Batch) ExecuteBatch()
Batching
Managing Concurrency GET GET Customer: ALFKI Country: Spain Customer: ALFKI Country: Spain
Managing Concurrency PUT Customer: ALFKI Country:  UK PUT Customer: ALFKI Country:  Germany
Managing Concurrency Optimistic concurrency Attribute used to specify properties Not necessary for Entity Framework data Standard HTTP protocol used  eTags used to send to client ( in XML if necessary ) HTTP If-match headers used to check when PUT/DELETE occurs ( 412 returned for failure )
Concurrency
Resources New Data Developer Site http://www.datadeveloper.net   Data Services (“Astoria”) Team Blog http://blogs.msdn.com/astoriateam   My website   http://www.miketaulty.com  ( search Data Services )
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation.  Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.  MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

ADO.NET Data Services

  • 1.
    ADO.NET Data ServicesMike Taulty Developer & Platform Group Microsoft Ltd [email_address] http://www.miketaulty.com
  • 2.
    Agenda The corebits that we’ll demo Overview of ADO.NET Data Services Exposing data sources Building clients Intercepting the server-side dispatch process The extra bits that we’ll talk about Dealing with batched operations Dealing with concurrency
  • 3.
    Data Services –Overview Provides new functionality CRUD access to data over RESTful web services Built-in URI-based query syntax Client-side libraries for .NET , AJAX and Silverlight Builds on top of WCF V3.5 Status In VS 2008 Service Pack 1 , Ships Summer 2008 Current version is in Sp1 Beta 1 but has been through various previews
  • 4.
    RESTful Web Services?Resources Res 1 Res 2 Res 3 Res 4 HTTP Request URL VERB Payload HTTP Response Status GET POST PUT DELETE XML JSON Payload XML JSON
  • 5.
    RESTful? RE presentational S tate T ransfer Server-side resources identified by a URI Access is over HTTP, verb tied to action GET to read the value of a resource POST to create a new resource PUT to update an existing resource DELETE to delete a resource Returned data is “plain” – XML or JSON Is this “the death of SOAP”?
  • 6.
    Data? What Kindof Data? Provide a type with public properties which are IQueryable<T> Some rules about how T has to be formed Remember the extension method AsQueryable() Only get write access if your type implements IUpdatable Works well with generated code from; ADO.NET Entity Framework ( ObjectContext ) LINQ to SQL ( DataContext *)
  • 7.
  • 8.
    ADO.NET Entity Framework? SQL Provider Oracle Provider ... Entity Provider Conceptual Model Store Model Map ADO.NET API ORM API
  • 9.
  • 10.
    Querying with DataServices URI based query mechanism http://myservice.svc/MyEntitySet Supports the notion of navigating by primary key MyEntitySet ( MyPrimaryKeyCol1, Col2, ... ) Supports various operators $orderby, $top, $skip, $expand, $filter, $value
  • 11.
  • 12.
  • 13.
    Building Clients Servicesoffer metadata MyService.svc/$metadata .NET clients made easier through a proxy generation tool datasvcutil.exe Useful for both regular .NET clients & Silverlight AJAX clients made easier through a script library “ Data Service AJAX Client Library” Available as a download on Codeplex
  • 14.
  • 15.
    Interception & OperationsPossible to hook code into the framework For queries we can write Query interceptors For modifications we can write Change interceptors Can also expose custom functionality Service Operations Useful for providing “canned” functionality, can be parameterised
  • 16.
  • 17.
    Batching of Operations“ INSERT” Customer 1 POST Order 1 POST Order 2 POST Order N POST
  • 18.
    Batching of Operations“ INSERT” Customer 1 Order 1 Order 2 Order N POST
  • 19.
    Batching of OperationsProvides a mechanism to process a batch 0 or more Query operations 0 or more [Create/Update/Delete] operations Uses multipart/mixed MIME type sent to a $batch endpoint Use SaveChanges(SaveChangesOptions.Batch) ExecuteBatch()
  • 20.
  • 21.
    Managing Concurrency GETGET Customer: ALFKI Country: Spain Customer: ALFKI Country: Spain
  • 22.
    Managing Concurrency PUTCustomer: ALFKI Country: UK PUT Customer: ALFKI Country: Germany
  • 23.
    Managing Concurrency Optimisticconcurrency Attribute used to specify properties Not necessary for Entity Framework data Standard HTTP protocol used eTags used to send to client ( in XML if necessary ) HTTP If-match headers used to check when PUT/DELETE occurs ( 412 returned for failure )
  • 24.
  • 25.
    Resources New DataDeveloper Site http://www.datadeveloper.net Data Services (“Astoria”) Team Blog http://blogs.msdn.com/astoriateam My website  http://www.miketaulty.com ( search Data Services )
  • 26.
    © 2008 MicrosoftCorporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Editor's Notes

  • #2 06/07/09 01:41 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.