1 / 40

Developing with REST and LINQ in SharePoint 2010

Developing with REST and LINQ in SharePoint 2010. Paul Schaeflein Manager, Advanced Technologies LaSalle Consulting Partners. Todd C. Bleeker, PhD Chief Software Architect Mindsharp. Session Objectives And Takeaway. Session Objectives: Explain SharePoint 2010 data technologies

cleta
Download Presentation

Developing with REST and LINQ in SharePoint 2010

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Developing with REST and LINQ in SharePoint 2010 Paul Schaeflein Manager, Advanced Technologies LaSalle Consulting Partners Todd C. Bleeker, PhD Chief Software Architect Mindsharp

  2. Session Objectives And Takeaway • Session Objectives: • Explain SharePoint 2010 data technologies • Show the relative strengths of each SharePoint data access technology • Present the new List Platform capabilities • Demonstrate how to interact with SharePoint data using the new SharePoint APIs • Takeaway • Visual Studio 2010 projects showing powerful ways to access SharePoint Data http://SharePoint.MindsharpBlogs.com/Todd/SPC

  3. Agenda • Overview of Data Technologies • Describe SharePoint 2010 List Data Model Enhancements • Demo new List Data Platform capabilities • Demo REST APIs • Demo Client OM • Demo LINQ to SharePoint

  4. 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

  5. Data PlatformScope List Data Model File System Lists Query External Lists

  6. List Data ModelList Lookups • Lookups form relationships between lists • One-to-many • Many-to-many Lookup Lookup 1 1 m m Clients Projects Timecards

  7. List Data ModelLists Relationships and Data Integrity • One-to-many relationships can be used to: • Trigger Cascade Delete • Restrict Delete Lookup Lookup 1 1 m m Clients Projects Timecards

  8. List Data ModelLists Joins and Projections • Query within and across lists: • Join lists using lookup columns • Lookup to multiple columns Lookup Lookup 1 1 m m Clients Projects Timecards Query Result Set

  9. List Data ModelValidation and Uniqueness • Validation Formula can be specified on List and Columns Example: =[Discount] < [Cost] • Column uniqueness constraint

  10. List Data ModelAutomatic large query throttling • Check query before execution • If Index is not used and number of scanned rows is greater than a limit then block query • If number of Joins is greater than limit then block query • If enabled on the Web Application, the developer can turn off throttling using:SPQuery.RequestThrottleOverride and SPSiteDataQuery.RequestThrottleOverride

  11. New List Capabilities demo Relationships, No Duplicates, Projection,Multi-Values Lookups, Data Integrity, Data Validation, Query Throttling

  12. Next: Client Object Model (OM) REST APIs Strongly-typed Client OM Weakly-typed Client-side Data Platform Farm Site List Data External Lists ServerOM Server-side Weakly-typed LINQ Strongly-typed New in 2010 Improved

  13. Client OMUnified Clients • Unified object model across all clients • JavaScript • .NET CLR • Silverlight CLR • Subset of Server OM • Webs, Lists, ListItems, • Content Types, Fields • etc.

  14. 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

  15. Using the Client OM JavaScript Logic JavaScript Controls JavaScript OM JSON response XmlHttpRequest.post Proxy XML Client.svc Server OM Web Browser HttpWebRequest.post Proxy XML JSON response Managed OM Content Database Managed Controls Managed Logic SharePoint Server Managed Client

  16. Client Object Model demo Accessing SharePoint Data using the JavaScript Client Object Model

  17. Next: REST APIs REST APIs Strongly-typed lists ClientOM Weakly-typed lists Client-side Data Platform Farm Site List Data External Lists ServerOM Server-side Weakly-typed lists LINQ Strongly-typed lists New in 2010 Improved

  18. REST APIsREST-style ListData.svc Web Service • Work with data viaRepresentational State Transfer (REST) • SharePoint list data • Other data sources as well • Excel spreadsheets • Azure cloud store • Powered by ADO.NET Data Services “Astoria” • REST Protocols: Atom, AtomPub, and JSON • Integration and Standardization

  19. 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

  20. REST APIsURI Map Filter • Syntax: • /_vti_bin/ListData.svc/{Entity}?$filter={simple predicate} • Example to get Projects for Clients in Chicago: • /_vit_bin/ListData.svc/Projects?$filter=Client/City eq 'Chicago'

  21. 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

  22. 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

  23. REST APIs demo Accessing SharePoint Data using the REST API from JavaScript

  24. Next: LINQ to SharePoint provider REST APIs Strongly-typed lists ClientOM Weakly-typed lists Client-side Data Platform Farm Site List Data External Lists ServerOM Server-side Weakly-typed lists LINQ Strongly-typed lists New in 2010 Improved

  25. LINQ to SharePointStrongly-typed access to List Data on Server • Entity based programming on the server • SPMetal Code Generation Utility • LINQ Queries • Strong Types • Translates LINQ queries into CAML queries • Can be used in • Web Parts, Event Receivers, Sandboxed code

  26. LINQ to SharePoint providerSample: Original LINQ query • from p indata.Projectswhere • p.Client.City == "Chicago"select new • { • Name = p.Title, • ClientName = p.Client.Title, • Budget = p.BudgetHours • };

  27. LINQ to SharePoint providerSample: Generated CAML 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>

  28. LINQ to SharePoint providerSample: Original LINQ query • fromtcindata.Timecardswhere • tc.Id == 4group tcby tc.WorkDate.Value.ToString("MM/yy") into tcs • select new • { • Month = tcs.Key, • Total = tcs.Sum(t => t.Hours) • };

  29. LINQ to SharePoint providerSample: Generated CAML Query • <Query> • <Where> • <And> • <BeginsWith> • <FieldRefName="ContentTypeId" /> • <ValueType="ContentTypeId">0x0100</Value> • </BeginsWith> • <Eq> • <FieldRefName="ID" /> • <ValueType="Counter">4</Value> • </Eq> • </And> • </Where> • </Query> • <ViewFields> • <FieldRefName="StaffId" /> • <FieldRefName="WorkDate" /> • <FieldRefName="Hours" /> • <FieldRefName="Project" /> • <FieldRefName="ID" /> • <FieldRefName="owshiddenversion" /> • <FieldRefName="Title" /> • </ViewFields> • <RowLimitPaged="TRUE">2147483647</RowLimit>

  30. LINQ to SharePoint demo Accessing Relational SharePoint Data using LINQ to SharePoint

  31. Data Technologies in SharePoint 2010 • SharePoint 2010 List Data Model • Relationships, Joins, and Data Integrity • 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

  32. Data Access TechnologiesDecision Matrix

  33. Data Access TechnologiesDecision Matrix

  34. Related Content at SPC 2009

  35. Questions • SharePoint kiosk: • In the Microsoft Pavilion • Immediately following session • Ask the Experts: • Wednesday Evening • 5:45pm – 7:30pm in the Exhibit Hall • Online: • http://sharepoint.mindsharpblogs.com/todd • http://sharepoint.mindsharpblogs.com/paul

  36. Remember to fill out your evaluations onMySPCfor your chance to win two HD web cams and a designer mouse (3 prizes awarded daily)

  37. Learn More about SharePoint 2010 Information forIT Prosat TechNet http://MSSharePointITPro.com Information forDevelopersat MSDN http://MSSharePointDeveloper.com Information forEveryone • http://SharePoint.Microsoft.com

  38. © 2009 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.

More Related