360 likes | 503 Views
SharePoint 2010 : Data Provider. The New way to connect data in SharePoint 2010. Renaud Comte [MVP] Renaud.comte@wygwam.com. www.wygwam.com. Wygwam Paris Wygwam Nord. Wygwam Belux. Wygwam Suisse. Session Objectives: . Overview of Data Technologies
E N D
SharePoint 2010 : Data Provider The New way to connect data in SharePoint 2010 Renaud Comte [MVP] Renaud.comte@wygwam.com
www.wygwam.com Wygwam Paris Wygwam Nord Wygwam Belux Wygwam Suisse
Session Objectives: • Overview of Data Technologies • Discover each SharePoint data access technology • Present the new List Platform capabilities • Demonstrate how to interact with SharePoint data using the new SharePoint APIs
Overview of Data Technologies REST APIs Strongly-typed ClientOM Weakly-typed Client-side Data Platform Farm Site List Data External Lists ServerOM Server-side Weakly-typed LINQ Strongly-typed New in 2010 Improved
List Data Improvements in SharePoint 2010 List & Relationnal
Lookups form relationships between lists One-to-many Many-to-many Lists and Lookups Projects Employees Clients Lookup Lookup m 1 m 1
List Relationships • Enforce Data Integrity • One-to-many relationships can be used to: • Trigger cascade delete • Restrict delete • Relationship behaviors (delete/restrict) are not supported on multi-value lookups
Large Lists • Set a limitfor how many rows of data can be retrieved for query before execution • List View Threshold • List View Threshold for Auditors and Administrators • List View Lookup Threshold • Daily Time Window for Large Queries • If enabled on the Web Application, developer can turn off throttling using: • SPQuery.RequestThrottleOverride • SPSiteDataQuery.RequestThrottleOverride
DEMO List Data Model by Code Lookup to Multiple Columns List Relationships Related Items UI
Query with the Server OM (and the Client OM) CAML is still here
Data engine query still use CAML Just for query ! Become relationnal CAML Queries 2010 - Main Changes
DEMO CAML 2010 in fact Lookup to Multiple Columns List Relationships Related Items UI
Linq for SharePoint aka SPLINQ
Entity based programming on the server SPMetal Code Generation Utility LINQ Queries Strong Types Translates LINQ queries into CAMLqueries Can be used in Web Parts, Event Receivers, Sandboxed code(Server OM only) Linq for SharePoint aka SPLINQ
LINQ to SharePoint Basics spmetal.exe SPLinq.cs SPLinq.vb spmetal/web:http://dataetch/code:SPLinq.cs SharePoint Site http://SPsomewhere SPLinqDataContext • SPLinqDataContext dc = new SPLinqDataContext (“http://SPsomewhere”); • var q=dc.Employees.Where(emp=>emp.DueDate < DateTime.Now.AddMonths(6)); • from o in data.Orderswhere o.Customer.City.Name == “San Francisco“select o;
Some details : Supports List Joins and Projections LINQ (lambda expressions, anonymous types, joins ...) can be used accross SharePoint lists Manage also Create/Update/Read/Delete operation Only "efficient" queries are supported by SPLINQ Beta 2. must be completed via LINQ to objects Change conflicts handling ... Linq for SharePoint aka SPLINQ
DEMO SPLINQ live Simple Query Join Query Data CRUD and relational Sync management
from p indata.Projectswhere p.Client.City == "Chicago"select new { Name = p.Title, ClientName = p.Client.Title, Budget = p.BudgetHours } LINQ to SharePointSample: Original LINQ query
<Query> <Where> <And> <BeginsWith> <FieldRefName="ContentTypeId" /> <ValueType="ContentTypeId">0x0100</Value> </BeginsWith> <Eq> <FieldRefName="ClientCity" /> <ValueType="Lookup">Chicago</Value> </Eq> </And> </Where> </Query> <ViewFields> <FieldRefName="Title" /> <FieldRefName="ClientTitle" /> <FieldRefName="BudgetHours" /> </ViewFields> <ProjectedFields> <FieldName="ClientTitle" Type="Lookup" List="Client" ShowField="Title" /> <FieldName="ClientCity" Type="Lookup" List="Client" ShowField="City" /> </ProjectedFields> <Joins> <JoinType="LEFT" ListAlias="Client"> <!--List Name: Clients--> <Eq> <FieldRefName="Client" RefType="ID" /> <FieldRefList="Client" Name="ID" /> </Eq> </Join> </Joins> LINQ to SharePointGenerated CAML Query
Client Object Model JS/SL/Win OM
Unified object model across all clients JavaScript,.NETCLR,SilverlightCLR Subset of Server OM Webs, Lists, ListItems,Content Types, Fields,etc. Client Object Model
Client OMGenerally How It Works Client Application Server Sequence of commands: Client.svc command 1; command 2; command 3; Execute commands in the batch: XML command 1; command 2; command 3; context.ExecuteQuery(); JSON Process results Send results back • Proxy to WCF • XML query / JSON response
Client Object Model : Pattern • Create a Client Connection • Create a Client Connection • Execute the Query ClientContextclientContext = new ClientContext("http://SPdata"); List list = clientContext.Web.Lists.GetByTitle(“Projects"); clientContext.Load(list); clientContext.ExecuteQuery();
Not an another OM !!! Simple API Server OM like ! It gives you Effienciency,Batch processing,Productivity,... Still need Context to load / Batch to execute CAML to query data ... Client Object Model : remarks
RESTful Data ServiceInterface Odata is coming
Work with data via Representational State Transfer (REST) Rss/Atom like : http://<site>/_vti_bin/ListData.svc SharePoint List Data Other Datasources Excel Services, Azure Cloud, ... Powered byWCF Data Services (ADO.NET Data Services v1.5 CTP2) Entity based programming Strong Types LINQ Queries REST API
Framework free The Open Data Protocol (OData) is a Web protocol for querying and updating data that provides a way to unlock your data and free it from silos that exist in applications today Easy to use, not too much technology dependency Good for client side developpement Just a new protocol (Atom like) Open to any another technology Data/Url Driven Full Integration with Visual Studio
REST APIsQueryString Parameters • $filter={simple predicate} • $expand={Entity} • $orderby={property} • $skip=n • $top=n • $metadata • See: http://msdn.microsoft.com/en-us/library/cc907912.aspx
REST APIsURI Map - Entity Properties • Syntax: • /_vti_bin/ListData.svc/{Entity}[({identifier})]/[{Property}] • Example to get budget hours for Project #4: • /_vit_bin/ListData.svc/Projects(4)/BudgetHours
REST APIsURI Map Filter • Syntax: • /_vti_bin/ListData.svc/{Entity}?$filter={simple predicate} • Example to get Projects for Clients in Geneva: • /_vit_bin/ListData.svc/Projects?$filter=Client/City eq ‘Geneva'
REST APIsURI Map – Expand (think Join) • Syntax: • /_vti_bin/ListData.svc/{Entity}?$expand={Entity} • Example to get a Project and its related Client: • /_vit_bin/ListData.svc/Projects?$expand=Client
DEMO REST now … From a real simple client side code : jquery to ...
SharePoint 2010 List Data Model Relationships, Joins, and Data Integrity Caml is still here but Linq also Client OM and Server OM Complete set of data APIs on both server and client side REST APIs and LINQ to SharePoint Simple and integrated developer experience for list based Data Applications Of course : SP2010 Data coding To sum up
Thank you for your Attention! • For more Information please contact • Name : Renaud Comte • Title : SharePoint Team Leader • Email : Renaud.Comte@wygwam.com