SharePoint 2010 opens up a wide range of options for developers, and this session will take you through the new SharePoint list Data Model Capabilities; LINQ to SharePoint; Client Object Model and RESTful Data Service Interface for SharePoint.
How to Troubleshoot Apps for the Modern Connected Worker
Developing With Data Technologies
1. Developing With Data Technologies Chakkaradeep Chandran http://www.chakkaradeep.com @chakkaradeep
2. Session Objectives and Takeaway Session Objectives: Explain SharePoint Data Technologies Present the new List Platform Capabilities Demonstrate how to interact with SharePoint data using: LINQ to SharePoint Client Object Model .NET CLR Silverlight CLR JavaScript CLR RESTful Data Service Interface Takeaway: Building applications using the various SharePoint 2020 Data Technologies
3. SharePoint 2010 for Developers Visual Studio 2010 Install on Windows 7 SharePoint Designer 2010 Developer Dashboard Developer Productivity Business Connectivity Services LINQ, REST and Data Improvements Client Object Model Silverlight Web Part ECMAScript Object Model (JavaScript,JSCript) Rich Platform Services Team Foundation Server Sandboxed Solutions WSP Solution Upgrade SharePoint Online Flexible Deployment
4. Overview of Data Technologies REST APIs Client OM Client Side Data Platform Server Side Farm Site List Data External Lists LINQ (spmetal.exe) ServerOM
6. Lists and Lookups Lookup Lookup Projects Employees Clients m 1 m 1 Lookups form relationships between lists One-to-many Many-to-many
7. 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
8. List Validation Validation Formula can be specified on List and Columns =[Column1]-[Column2] =AND([Column1]>[Column2], [Column1]<[Column3]) =PRODUCT([Column1],[Column2],2) =DATEDIF([Column1], [Column2],"d") =CONCATENATE([Column2], ",", [Column1])
9. Large Lists Set a limit for how many rows of data can be retrieved for a list or library at any one time: 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
11. List Data Model Lookup to Multiple Columns List Relationships Related Items UI List Validation
12. Summary : List Data Improvements REST APIs Client OM Client Side Data Platform Server Side Farm Site List Data External Lists LINQ (spmetal.exe) ServerOM
14. Building Server Applications .aspx.cs Server OM SharePoint data SharePoint data Classes & Objects SharePoint Site
15. Server Object Model Example Code Using Microsoft.SharePoint; List<Announcement> announcements = new List<Announcement>(); SPSitesite = SPContext.GetContext(HttpContext.Current).Site; using (SPWebcurWeb = site.OpenWeb()) { SPListlstAnnouncements = curWeb.Lists[new Guid(LibraryName)]; //rest of the code }
17. LINQ to SharePoint Entity based programming Strong Types and Intellisense Translates LINQ queries to CAML queries Supports List Joins and Projections Join lists on lookup field between them Join multiple lists (A->B->C) Project any field from joined list in a query without changes in list schema Can be used in Web Parts Event Receivers Sandboxed Code
18. LINQ to SharePoint Basics spmetal.exe SPLinq.cs SPLinq.vb spmetal/web:http://dataetch/code:SPLinq.cs SharePoint Site http://datatech SPLinqDataContext SPLinqDataContext dc = new SPLinqDataContext (“http://datatech”); 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;
22. SPMetal Parameters XML File SPMetal does not require a parameters XML file To include or exclude a different set of lists and columns from the default <?xmlversion="1.0" encoding="utf-8"?> <WebAccessModifier="Internal" xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal"> <ContentTypeName="Contact" Class="Contact"> <ColumnName="ContId" Member="ContactId" /> <ColumnName="ContactName" Member="ContactName1" /> <ColumnName="Category" Member="Cat" Type="String"/> <ExcludeColumnName="HomeTelephone" /> </ContentType> <ExcludeContentTypeName="Order"/> <ListName=”Team Members” Type=”TeamMember”> <ContentTypeName=”Item” Class=”TeamMember” /> </List> </Web>
24. Summary : LINQ to SharePoint REST APIs Client OM Client Side Data Platform Server Side Farm Site List Data External Lists LINQ (spmetal.exe) ServerOM
26. Building Client Applications – MOSS 2007 {code} Web Services {SharePoint data} SharePoint Site SharePoint API {SharePoint data}
27. Client Object Model – SharePoint 2010 {code} {SharePoint data} Client Object Model {SharePoint data} SharePoint Site
28. Client Object Model Example Code class ClientOM { using Microsoft.SharePoint.Client; static void Main() { ClientContextclientContext= new ClientContext("http://datatech"); Web oWebsite = clientContext.Web; clientContext.Load(oWebsite); clientContext.ExecuteQuery(); Console.WriteLine(oWebsite.Title); } }
30. Client Object Model – How It Works WCF Service (Client.svc) JavaScript Application Server OM JSON Response JavaScript OM SharePoint Site XML Request Proxy XML Request Proxy JSON Response Managed OM Managed Code Application (.NET)
31. Client Object Model – How It Works Client Application Server Sequence of commands: command 1; command 2; command 3; context.ExecuteQuery(); client.svc Execute commands in the batch: command 1; command 2; command 3; Send results back XML JSON Process results
32. ClientContextclientContext= new ClientContext("http://sptechcon"); List list= clientContext.Web.Lists.GetByTitle(“Workshops"); CamlQuerycamlQuery = new CamlQuery(); camlQuery.ViewXml= "<View/>"; ListItemCollectionlistItems= list.GetItems(camlQuery); clientContext.Load(list); clientContext.Load(listItems); clientContext.ExecuteQuery(); foreach(ListItemlistItem in listItems) Console.WriteLine("Id: {0} Title: {1}", listItem.Id,listItem["Title"]); Client Object Model – Object Identity
33. Client Object Model – The Pattern Create a Client Connection Create the Query Execute the Query ClientContextclientContext = new ClientContext("http://datatech"); clientContext.ExecuteQuery(); List list = clientContext.Web.Lists.GetByTitle(“Projects"); clientContext.Load(list);
34. Client Object Model – Trimming the Results Title Property Web SharePoint Site Lists Collection Title Property Id Property
35. .NET CLR Client Object Model Requires two assemblies: Microsoft.SharePoint.Client Microsoft.SharePoint.Client.Runtime Develop solutions remotely
36. .NET Client OM Using CAML Query Object Identity Trimming The Results Creating and Populating a List Updating Client Objects Deleting Client Objects Asynchronous Pattern
37. Silverlight CLR Client Object Model Requires two assemblies: Microsoft.SharePoint.Client.Silverlight Microsoft.SharePoint.Client.Silverlight.Runtime Develop solutions remotely
39. JavaScript Client Object Model Minified .js files for the ECMAScript (JavaScript, JScript) object model: SP.js SP.Core.js SP.Ribbon.js SP.Runtime.js Browser Support for ECMA Script: Microsoft Internet Explorer 7 and greater Firefox 3.5 and greater Safari 4.0 and greater Develop solutions remotely
41. Summary : Client Object Model REST APIs Client OM Client Side Data Platform Server Side Farm Site List Data External Lists LINQ (spmetal.exe) ServerOM
43. RESTful Data Service Interface REST-style list data web service http://<site>/_vti_bin/ListData.svc Work with data via REST SharePoint List Data Powered by ADO.NET Data Services ADO.NET Data Services v1.5 CTP2 Entity based programming Strong Types LINQ Queries Integration with Visual Studio
44. REST API QueryString Parameters $filter={simple predicate} $expand={Entity} $orderby={property} $skip=n $top=n $metadata Full List - http://bit.ly/RESTfulAPI
47. Summary REST APIs Client OM Client Side Data Platform Server Side Farm Site List Data External Lists LINQ (spmetal.exe) ServerOM
48. Thank You chaks@intergen.co.nz http://www.chakkaradeep.com/category/SharePoint-2010.aspx http://twitter.com/chakkaradeep
Notas do Editor
Here is an overall view of the SharePoint data technologies platform. Developers can make use of these technologies to build SharePoint applications. SharePoint 2010 introduces more additions to the already available SharePoint 2007 technologies.Explain the client side and server side framework:Client OMREST APIsSPLINQ
Microsoft SharePoint Foundation offers a highly structured server-side object model that makes it easy to access objects that represent the various aspects of a SharePoint Web site. From higher-level objects, you can drill down through the object hierarchy to obtain the object that contains the members you need to use in your code.
Sample custom application: You may want to create custom .aspx pages and Web applications and store them in a location that is accessible from all Web sites in your Microsoft SharePoint Foundation 2010 deploymentDeveloper writes code (.aspx.cs) using the Server OMServer OM interacts with the SharePoint site, retrieves the data from the SharePoint siteThe .aspx page displays the SharePoint data