Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Developing With Data Technologies

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.

  • Login to see the comments

Developing With Data Technologies

  1. 1. Developing With Data Technologies<br />Chakkaradeep Chandran<br /><br />@chakkaradeep<br />
  2. 2. Session Objectives and Takeaway<br />Session Objectives:<br />Explain SharePoint Data Technologies<br />Present the new List Platform Capabilities<br />Demonstrate how to interact with SharePoint data using:<br />LINQ to SharePoint<br />Client Object Model<br />.NET CLR<br />Silverlight CLR<br />JavaScript CLR<br />RESTful Data Service Interface<br />Takeaway:<br />Building applications using the various SharePoint 2020 Data Technologies<br />
  3. 3. SharePoint 2010 for Developers<br />Visual Studio 2010<br />Install on Windows 7<br />SharePoint Designer 2010<br />Developer Dashboard<br />Developer Productivity<br />Business Connectivity Services <br />LINQ, REST and Data Improvements<br />Client Object Model<br />Silverlight Web Part<br />ECMAScript Object Model (JavaScript,JSCript)<br />Rich Platform Services<br />Team Foundation Server<br />Sandboxed Solutions<br />WSP Solution Upgrade<br />SharePoint Online<br />Flexible Deployment<br />
  4. 4. Overview of Data Technologies<br />REST APIs<br />Client OM<br />Client Side<br />Data Platform<br />Server Side<br />Farm<br />Site<br />List Data<br />External Lists<br />LINQ<br />(spmetal.exe)<br />ServerOM<br />
  5. 5. List Data Improvements in SharePoint 2010<br />
  6. 6. Lists and Lookups<br />Lookup<br />Lookup<br />Projects<br />Employees<br />Clients<br />m<br />1<br />m<br />1<br />Lookups form relationships between lists<br />One-to-many<br />Many-to-many<br />
  7. 7. List Relationships<br />Enforce Data Integrity<br />One-to-many relationships can be used to:<br />Trigger cascade delete<br />Restrict delete<br />Relationship behaviors (delete/restrict) are not supported on multi-value lookups<br />
  8. 8. List Validation<br />Validation Formula can be specified on List and Columns<br />=[Column1]-[Column2]<br />=AND([Column1]&gt;[Column2], [Column1]&lt;[Column3])<br />=PRODUCT([Column1],[Column2],2)<br />=DATEDIF([Column1], [Column2],&quot;d&quot;)<br />=CONCATENATE([Column2], &quot;,&quot;, [Column1])<br />
  9. 9. Large Lists<br />Set a limit for how many rows of data can be retrieved for a list or library at any one time:<br />List View Threshold<br />List View Threshold for Auditors and Administrators<br />List View Lookup Threshold<br />Daily Time Window for Large Queries<br />If enabled on the Web Application, developer can turn off throttling using:<br />SPQuery.RequestThrottleOverride<br />SPSiteDataQuery.RequestThrottleOverride<br />
  10. 10. List View Threshold<br />
  11. 11. List Data Model<br />Lookup to Multiple Columns<br />List Relationships<br />Related Items UI<br />List Validation<br />
  12. 12. Summary : List Data Improvements<br />REST APIs<br />Client OM<br />Client Side<br />Data Platform<br />Server Side<br />Farm<br />Site<br />List Data<br />External Lists<br />LINQ<br />(spmetal.exe)<br />ServerOM<br />
  13. 13. Server Object<br />Model<br />
  14. 14. Building Server Applications<br />.aspx.cs<br />Server OM<br />SharePoint data<br />SharePoint data<br />Classes & Objects<br />SharePoint Site<br />
  15. 15. Server Object Model Example Code<br />Using Microsoft.SharePoint;<br />List&lt;Announcement&gt; announcements = new List&lt;Announcement&gt;(); <br />SPSitesite = SPContext.GetContext(HttpContext.Current).Site; <br />using (SPWebcurWeb = site.OpenWeb()) <br />{ <br />SPListlstAnnouncements = <br />curWeb.Lists[new Guid(LibraryName)];   <br />//rest of the code <br />}<br />
  16. 16. LINQ to SharePoint<br />(SPLinq)<br />
  17. 17. LINQ to SharePoint<br />Entity based programming<br />Strong Types and Intellisense<br />Translates LINQ queries to CAML queries<br />Supports List Joins and Projections<br />Join lists on lookup field between them<br />Join multiple lists (A-&gt;B-&gt;C)<br />Project any field from joined list in a query without changes in list schema<br />Can be used in<br />Web Parts<br />Event Receivers<br />Sandboxed Code<br />
  18. 18. LINQ to SharePoint Basics<br />spmetal.exe<br />SPLinq.cs<br />SPLinq.vb<br />spmetal/web:http://dataetch/code:SPLinq.cs<br />SharePoint Site<br />http://datatech<br />SPLinqDataContext<br />SPLinqDataContext dc = new SPLinqDataContext (“http://datatech”);<br />var q=dc.Employees.Where(emp=&gt;emp.DueDate &lt; DateTime.Now.AddMonths(6));<br />from o in data.Orderswhere o.Customer.City.Name == “San Francisco“select o;<br />
  19. 19. SPMetal Options<br />
  20. 20. LINQ to SharePoint<br />
  21. 21. SPMetal – Default Code Generation Rules<br />spmetal.exe<br />SPLinqDataContext<br />Project<br />Projects<br />Class<br />Property<br />GetProjects<br />
  22. 22. SPMetal Parameters XML File<br />SPMetal does not require a parameters XML file<br />To include or exclude a different set of lists and columns from the default<br />&lt;?xmlversion=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />&lt;WebAccessModifier=&quot;Internal&quot; xmlns=&quot;;&gt;<br />&lt;ContentTypeName=&quot;Contact&quot; Class=&quot;Contact&quot;&gt;<br /> &lt;ColumnName=&quot;ContId&quot; Member=&quot;ContactId&quot; /&gt;<br /> &lt;ColumnName=&quot;ContactName&quot; Member=&quot;ContactName1&quot; /&gt;<br /> &lt;ColumnName=&quot;Category&quot; Member=&quot;Cat&quot; Type=&quot;String&quot;/&gt;<br /> &lt;ExcludeColumnName=&quot;HomeTelephone&quot; /&gt;<br />&lt;/ContentType&gt;<br />&lt;ExcludeContentTypeName=&quot;Order&quot;/&gt;<br />&lt;ListName=”Team Members” Type=”TeamMember”&gt;<br /> &lt;ContentTypeName=”Item” Class=”TeamMember” /&gt;<br />&lt;/List&gt;<br />&lt;/Web&gt;<br />
  23. 23. LINQ to SharePoint: Parameters XML File<br />
  24. 24. Summary : LINQ to SharePoint<br />REST APIs<br />Client OM<br />Client Side<br />Data Platform<br />Server Side<br />Farm<br />Site<br />List Data<br />External Lists<br />LINQ<br />(spmetal.exe)<br />ServerOM<br />
  25. 25. Client ObjectModel<br />
  26. 26. Building Client Applications – MOSS 2007<br />{code}<br />Web Services<br />{SharePoint data}<br />SharePoint Site<br />SharePoint API<br />{SharePoint data}<br />
  27. 27. Client Object Model – SharePoint 2010<br />{code}<br />{SharePoint data}<br />Client Object Model<br />{SharePoint data}<br />SharePoint Site<br />
  28. 28. Client Object Model Example Code<br />class ClientOM<br />{ <br />using Microsoft.SharePoint.Client;<br /> static void Main() <br />{ <br />ClientContextclientContext=<br /> new ClientContext(&quot;http://datatech&quot;); <br /> Web oWebsite = clientContext.Web; <br />clientContext.Load(oWebsite); <br />clientContext.ExecuteQuery();<br />Console.WriteLine(oWebsite.Title); <br />} <br />}<br />
  29. 29. Client OM<br />
  30. 30. Client Object Model – How It Works<br />WCF Service<br />(Client.svc)<br />JavaScript Application<br />Server OM<br />JSON Response<br />JavaScript OM<br />SharePoint Site<br />XML Request<br />Proxy<br />XML Request<br />Proxy<br />JSON Response<br />Managed OM<br />Managed Code Application (.NET)<br />
  31. 31. Client Object Model – How It Works<br />Client Application<br />Server<br />Sequence of commands:<br />command 1;<br />command 2;<br />command 3;<br />context.ExecuteQuery();<br />client.svc<br />Execute commands<br />in the batch:<br />command 1;<br />command 2;<br />command 3;<br />Send results back<br />XML<br />JSON<br />Process results<br />
  32. 32. ClientContextclientContext= new ClientContext(&quot;http://sptechcon&quot;);<br />List list= clientContext.Web.Lists.GetByTitle(“Workshops&quot;);<br />CamlQuerycamlQuery = new CamlQuery();<br />camlQuery.ViewXml= &quot;&lt;View/&gt;&quot;;<br />ListItemCollectionlistItems= list.GetItems(camlQuery);<br />clientContext.Load(list);<br />clientContext.Load(listItems);<br />clientContext.ExecuteQuery();<br />foreach(ListItemlistItem in listItems)<br />   Console.WriteLine(&quot;Id: {0} Title: {1}&quot;, listItem.Id,listItem[&quot;Title&quot;]);<br />Client Object Model – Object Identity<br />
  33. 33. Client Object Model – The Pattern<br />Create a Client Connection<br />Create the Query<br />Execute the Query<br />ClientContextclientContext = new ClientContext(&quot;http://datatech&quot;);<br />clientContext.ExecuteQuery();<br />List list = clientContext.Web.Lists.GetByTitle(“Projects&quot;);<br />clientContext.Load(list);<br />
  34. 34. Client Object Model – Trimming the Results<br />Title<br />Property<br />Web<br />SharePoint Site<br />Lists<br />Collection<br />Title<br />Property<br />Id<br />Property<br />
  35. 35. .NET CLR Client Object Model<br />Requires two assemblies:<br />Microsoft.SharePoint.Client<br />Microsoft.SharePoint.Client.Runtime<br />Develop solutions remotely<br />
  36. 36. .NET Client OM<br />Using CAML Query<br />Object Identity<br />Trimming The Results<br />Creating and Populating a List<br />Updating Client Objects<br />Deleting Client Objects<br />Asynchronous Pattern<br />
  37. 37. Silverlight CLR Client Object Model<br />Requires two assemblies:<br />Microsoft.SharePoint.Client.Silverlight<br />Microsoft.SharePoint.Client.Silverlight.Runtime<br />Develop solutions remotely<br />
  38. 38. Silverlight Client OM<br />
  39. 39. JavaScript Client Object Model<br />Minified .js files for the ECMAScript (JavaScript, JScript) object model:<br />SP.js<br />SP.Core.js<br />SP.Ribbon.js<br />SP.Runtime.js<br />Browser Support for ECMA Script:<br />Microsoft Internet Explorer 7 and greater<br />Firefox 3.5 and greater<br />Safari 4.0 and greater<br />Develop solutions remotely<br />
  40. 40. JavaScript Client OM<br />
  41. 41. Summary : Client Object Model<br />REST APIs<br />Client OM<br />Client Side<br />Data Platform<br />Server Side<br />Farm<br />Site<br />List Data<br />External Lists<br />LINQ<br />(spmetal.exe)<br />ServerOM<br />
  42. 42. RESTful Data ServiceInterface<br />
  43. 43. RESTful Data Service Interface<br />REST-style list data web service<br />http://&lt;site&gt;/_vti_bin/ListData.svc<br />Work with data via REST<br />SharePoint List Data<br />Powered by ADO.NET Data Services<br />ADO.NET Data Services v1.5 CTP2<br />Entity based programming<br />Strong Types<br />LINQ Queries<br />Integration with Visual Studio<br />
  44. 44. REST API QueryString Parameters<br />$filter={simple predicate}<br />$expand={Entity}<br />$orderby={property}<br />$skip=n<br />$top=n<br />$metadata<br />Full List -<br />
  45. 45. Makes Development Easy!<br />
  46. 46. Accessing List Data via REST APIs<br />
  47. 47. Summary<br />REST APIs<br />Client OM<br />Client Side<br />Data Platform<br />Server Side<br />Farm<br />Site<br />List Data<br />External Lists<br />LINQ<br />(spmetal.exe)<br />ServerOM<br />
  48. 48. Thank You<br /><br /><br /><br />