ADO.NET Data Services
-
Upload
ukdpe -
Category
Technology
-
view
1.658 -
download
2
description
Transcript of ADO.NET Data Services
![Page 1: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/1.jpg)
1
ADO.NET Data Services
Mike TaultyDeveloper & Platform GroupMicrosoft [email protected] http://www.miketaulty.com
![Page 2: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/2.jpg)
Agenda
The core bits that we’ll demoOverview of ADO.NET Data ServicesExposing data sourcesBuilding clientsIntercepting the server-side dispatch process
The extra bits that we’ll talk aboutDealing with batched operationsDealing with concurrency
![Page 3: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/3.jpg)
Data Services – Overview
Provides new functionalityCRUD access to data over RESTful web servicesBuilt-in URI-based query syntaxClient-side libraries for .NET, AJAX and Silverlight
Builds on top of WCF V3.5Status
In VS 2008 Service Pack 1, Ships Summer 2008Current version is in Sp1 Beta 1 but has been through various previews
![Page 4: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/4.jpg)
RESTful Web Services?
Resources
Res 1
Res 2
Res 3
Res 4
HTTP RequestURL
VERBPayload
HTTP Response
Status
GETPOSTPUT
DELETEXML JSON
Payload
XML JSON
![Page 5: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/5.jpg)
RESTful?
REpresentational State TransferServer-side resources identified by a URIAccess is over HTTP, verb tied to action
GET to read the value of a resourcePOST to create a new resourcePUT to update an existing resourceDELETE to delete a resource
Returned data is “plain” – XML or JSONIs this “the death of SOAP”?
![Page 6: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/6.jpg)
Data? What Kind of Data?
Provide a type with public properties which are IQueryable<T>
Some rules about how T has to be formedRemember the extension method AsQueryable()
Only get write access if your type implements IUpdatableWorks well with generated code from;
ADO.NET Entity Framework (ObjectContext)LINQ to SQL (DataContext*)
![Page 7: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/7.jpg)
7
Exposing Data
![Page 8: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/8.jpg)
ADO.NET Entity Framework ?
SQL Provider Oracle Provider ...
Entity Provider
Conceptual Model
Store Model
Map
ADO.NET API ORM API
![Page 9: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/9.jpg)
9
Using Entity Framework Data
![Page 10: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/10.jpg)
Querying with Data Services
URI based query mechanismhttp://myservice.svc/MyEntitySet
Supports the notion of navigating by primary key
MyEntitySet ( MyPrimaryKeyCol1, Col2, ... )Supports various operators
$orderby, $top, $skip, $expand, $filter, $value
![Page 11: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/11.jpg)
Operators for $filter
![Page 12: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/12.jpg)
12
Querying with the URI
![Page 13: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/13.jpg)
Building Clients
Services offer metadataMyService.svc/$metadata
.NET clients made easier through a proxy generation tool
datasvcutil.exeUseful 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
![Page 14: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/14.jpg)
14
Building Clients
![Page 15: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/15.jpg)
Interception & Operations
Possible to hook code into the frameworkFor queries we can write
Query interceptorsFor modifications we can write
Change interceptorsCan also expose custom functionality
Service OperationsUseful for providing “canned” functionality, can be parameterised
![Page 16: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/16.jpg)
16
Interception, Operations
![Page 17: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/17.jpg)
Batching of Operations
“INSERT”
Customer 1
POST
Order 1
POST
Order 2
POST
Order N
POST
![Page 18: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/18.jpg)
Batching of Operations
“INSERT”
Customer 1
Order 1
Order 2
Order N
POST
![Page 19: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/19.jpg)
Batching of Operations
Provides a mechanism to process a batch0 or more Query operations0 or more [Create/Update/Delete] operations
Uses multipart/mixed MIME type sent to a $batch endpointUse
SaveChanges(SaveChangesOptions.Batch)ExecuteBatch()
![Page 20: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/20.jpg)
Managing Concurrency
GET
GET
Customer: ALFKICountry: Spain
Customer: ALFKICountry: Spain
![Page 21: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/21.jpg)
Managing Concurrency
PUTCustomer: ALFKICountry: UK
PUTCustomer: ALFKICountry: Germany
![Page 22: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/22.jpg)
Managing Concurrency
Optimistic concurrencyAttribute used to specify properties
Not necessary for Entity Framework dataStandard 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 )
![Page 23: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/23.jpg)
Resources
New Data Developer Sitehttp://www.datadeveloper.net
Data Services (“Astoria”) Team Bloghttp://blogs.msdn.com/astoriateam
My website http://www.miketaulty.com ( search Data Services )
![Page 24: ADO.NET Data Services](https://reader038.fdocuments.net/reader038/viewer/2022102922/5490fe54b4795936048b48ad/html5/thumbnails/24.jpg)
© 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.