ado.net data services mike taulty developer & platform group microsoft uk...
TRANSCRIPT
![Page 1: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/1.jpg)
![Page 2: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/2.jpg)
ADO.NET DATA SERVICES
Mike TaultyDeveloper & Platform GroupMicrosoft [email protected] http://www.miketaulty.com
![Page 3: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/3.jpg)
Agenda
• Overview of ADO.NET Data Services• Exposing Data Sources
– Custom data sources, LINQ to SQL, LINQ to Entities
• Building Clients– .NET Clients, AJAX based clients
• More “advanced” topics– Interception– Service Operations– Batching of operations– Dealing with concurrency
![Page 4: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/4.jpg)
Data Services – Overview
• Builds on top of WCF V3.5• 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
• Status– In VS 2008 Service Pack 1, Ships Summer 2008
– Current version is in Sp1 Beta 1 but has been through various previews
![Page 5: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/5.jpg)
RESTful Web Services?
ResourcesRes
1Res 2Res 3Res 4
HTTP RequestURL
VERBPayload
HTTP Response
Status
GETPOSTPUT
DELETEXML JSON
Payload
XML JSON
![Page 6: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/6.jpg)
RESTful?
• REpresentational State Transfer– 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”?
![Page 7: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/7.jpg)
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*)
![Page 8: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/8.jpg)
DEMOExposing Data with ADO.NET Data Services
![Page 9: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/9.jpg)
ADO.NET Entity Framework????
SQL Provider Oracle Provider ...
Entity Provider
Conceptual Model
Store Model
Map
ADO.NET API ORM API
![Page 10: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/10.jpg)
DEMOExposing EF Data with ADO.NET Data Services
![Page 11: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/11.jpg)
Querying with ADO.NET 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
![Page 12: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/12.jpg)
Operators for $filterLogic
eqnegtgteqltlteqandornot
Arithmetic
addsubmuldivmodroundfloorceiling
String
containsendswithstartswithlengthindexofinsertremove x 2replacesubstringtolowertouppertrimconcat
Date/Time
secondhourminutedaymonthyear
Type
isofcast
![Page 13: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/13.jpg)
DEMOQuerying Data with the URI
![Page 14: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/14.jpg)
Building Clients
• Services offer metadata– MyService.svc/$metadata
• .NET clients made easier through a proxy generation tool– datasvcutil.exe
• AJAX clients made easier through a script library– Data Service AJAX Client Library
– Available as a download on Codeplex
![Page 15: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/15.jpg)
DEMOBuilding .NET and AJAX clients
![Page 16: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/16.jpg)
Interception & Operations
• Possible to hook code into the dispatch mechanism
• 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
![Page 17: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/17.jpg)
DEMOInterception and Service Operations
![Page 18: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/18.jpg)
Batching of Operations
“INSERT”
Customer 1
POST
Order 1
POST
Order 2
POST
Order N
POST
![Page 19: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/19.jpg)
Batching of Operations
“INSERT”
Customer 1
Order 1
Order 2
Order N
POST
![Page 20: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/20.jpg)
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()
![Page 21: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/21.jpg)
DEMOBatching of Operations
![Page 22: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/22.jpg)
Managing Concurrency
GET
GET
Customer: ALFKICountry: Spain
Customer: ALFKICountry: Spain
![Page 23: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/23.jpg)
Managing Concurrency
PUTCustomer: ALFKICountry: UK
PUTCustomer: ALFKICountry: Germany
![Page 24: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/24.jpg)
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 )
![Page 25: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/25.jpg)
DEMOManaging Concurrency
![Page 26: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/26.jpg)
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 )
![Page 27: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/27.jpg)
ADO.NET DATA SERVICES
Mike TaultyDeveloper & Platform GroupMicrosoft [email protected] http://www.miketaulty.com
![Page 28: ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK Mike.Taulty@microsoft.com](https://reader035.vdocument.in/reader035/viewer/2022062517/56649e865503460f94b8a125/html5/thumbnails/28.jpg)