Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hilton Giesenow - The MOSS Show Developing with LINQ, REST & the New Client OM in Microsoft SharePoint 2010 SESSION CODE: OFC322.

Similar presentations


Presentation on theme: "Hilton Giesenow - The MOSS Show Developing with LINQ, REST & the New Client OM in Microsoft SharePoint 2010 SESSION CODE: OFC322."— Presentation transcript:

1

2 Hilton Giesenow - The MOSS Show Developing with LINQ, REST & the New Client OM in Microsoft SharePoint 2010 SESSION CODE: OFC322

3 3 Agenda Accessing SharePoint data – then & now List data model improvements in 2010 LINQ To SharePoint Client Object Model REST Special thanks to…

4 4 Accessing SharePoint Data – circa 2007 Server Object Model Weakly typed Lots of XML Long-winded Non-standard Non-relational Garbage collection Web Services Weakly typed TONS of XML Long-winded Non-standard Non-relational No WCF Non standards-compliant No flexibility

5 5 Overview of Data Technologies LINQLINQ Data Platform Farm Site List Data External Lists Server OM Client OM REST APIs Web Web Services

6 6 The Case Study - List Lookups Lookups form relationships between lists One-to-many Many-to-many Restrict / Cascade Deletes

7 7 List Data Model - Lists Joins and Projections Query within and across lists: Join lists using lookup columns Lookup to multiple columns Query Result Set

8 8 Take Note: List Validation and Uniqueness Excel-like validation formula Can be specified on Columns and Lists Example: =[Discount] < [Cost] Column uniqueness constraint

9 9 Take Note: Query Throttling Check query before execution No index and count > limit Joins > limit Can turn throttling off using SPQuery.RequestThrottleOverride SPSiteDataQuery.RequestThrottleOverride

10 10 Relationships Multi-Value Lookups Data Integrity & Data Validation Query Throttling

11 11 Querying SharePoint, circa 2007 1500 500

12 12 And the Code to Get There… SPQuery query = new SPQuery(); StringBuilder sbQuery = new StringBuilder(); sbQuery.Append(" "); sbQuery.Append(" "); sbQuery.Append(" "); sbQuery.Append(" " + field Value1 + " "); sbQuery.Append(" "); sbQuery.Append(" "); query.Query = sbQuery.ToString();

13 13 Joins in CAML 0x0100 Durban

14 14 And the Code to Get There… using (SPSite site = new SPSite(SPContext.Current.Site)) { SPWeb web = site.RootWeb; if (web != null) { SPList list = web.Lists["Parents"]; if (list != null) { SPQuery query = new SPQuery(); StringBuilder sbQuery = new StringBuilder(); sbQuery.Append(" "); sbQuery.Append(" My Other Child "); sbQuery.Append(" "); query.Query = sbQuery.ToString(); StringBuilder sbJoins = new StringBuilder(); sbJoins.Append(" "); query.Joins = sbJoins.ToString(); StringBuilder sbProj = new StringBuilder(); sbProj.Append(" "); query.ProjectedFields = sbProj.ToString(); StringBuilder sbView = new StringBuilder(); sbView.Append(" "); query.ViewFields = sbView.ToString(); if (!string.IsNullOrEmpty(query.Query)) { SPListItemCollection matches = list.GetItems(query); foreach (SPListItem match in matches) { Console.WriteLine(match["Title"]); string rawNickname = (string)match["OtherChildrenNickname"]; if (!string.IsNullOrEmpty(rawNickname)) { SPFieldLookupValue nickname = new SPFieldLookupValue(rawNickname); Console.WriteLine(nickname.LookupValue); }

15 15 Overview of Data Technologies LINQLINQ Data Platform Farm Site List Data External Lists Server OM Client OM REST APIs Web Web Services

16 16 LINQ var CommonWords = from w in wordOccurances from w in wordOccurances where w.Count > 2 where w.Count > 2 select new { f.Name, w.Word, W.Count }; select new { f.Name, w.Word, W.Count }; var CommonWords = wordOccurances wordOccurances.Where(w => w.Count > 2).Where(w => w.Count > 2).Select(w => new {f.Name, w.Word, W.Count });.Select(w => new {f.Name, w.Word, W.Count }); Extension methods Lambda expressions Query expressions Object initializers Anonymous types Local variable type inference

17 17 LinQ to…

18 18 Objects XML.NET Language Integrated Query C# 3.0 VB 9.0 Others… Relational LINQ to Objects LINQ to SQL LINQ to XML LINQ to Entities LINQ Architecture LINQ to SharePoint SharePoint (CAML)

19 19 LINQ to SQL from p in dataContext.Projects where p.Client.City == Durban" select new { Name = p.Title, ClientName = p.Client.Title, Budget = p.BudgetHours };

20 20 LINQ to SQL – It's Just SQL Underneath SELECT [t0].[Title] AS [Name], [t1].[Title] AS [ClientName], [t0].[BudgetHours] AS [Budget] FROM [dbo].[Projects] AS [t0] INNER JOIN [dbo].[Clients] AS [t1] ON [t1].[ID] = [t0].[ClientID] WHERE [t1].[City] = 'Durban'

21 21 LINQ to SharePoint from p in dataContext.Projects where p.Client.City == Durban" select new { Name = p.Title, ClientName = p.Client.Title, Budget = p.BudgetHours };

22 22 LINQ to SharePoint – It's Just CAML Underneath 0x0100 Durban

23 23 Accessing Relational SharePoint Data using LINQ to SharePoint

24 24 LINQ to SharePoint – Some Limitations Unsupported Queries & Limits E.g. unsupported JOINS Join Limits - MS recommends < 8 Query Throttling 2-stage queries E.g. Aggregate, Distinct, Max, Min, Sum, SkipWhile Cross-site-collections Anonymous users

25 25 Overview / Summary SQL Metal Strong Typing Relationships Deferred Execution (& client-side queries) Some limitations

26 26 Overview of Data Technologies LINQLINQ Data Platform Farm Site List Data External Lists Server OM Client OM REST APIs Web Web Services

27 27 Client OM Server Side SharePoint SharePoint Web services End Client Win SL JS Client OM

28 28 Accessing SharePoint Data using the Client OM

29 29 Overview / Summary Much easier than before (asmx only) asmx web services still there if we need them Not limited to defined API Supports 3 client types Managed Clients (sync) Silverlight (async) Javascript (async)

30 30 Overview of Data Technologies LINQLINQ Data Platform Farm Site List Data External Lists Server OM Client OM REST APIs Web Web Services

31 31 SOAP Vs. REST i.e. Whats Wrong With SOAP? The Envelope Bloated Not actually 100% interoperable NOT fun from, e.g., Javascript The RPC-style Need to define entire interface operations, params, return types Leads to inconsistencies over time Documentation

32 32 REST APIs WCF is now supported! What is Representational State Transfer (REST)? And what is OData? Strongly typed (depending on tools...) WCF Data Services Astoria

33 33

34 34 REST (OData) APIs Syntax: /_vti_bin/ListData.svc/{Entity}[({identifier})]/[{Property}] Example to get budget hours for Project #4: /_vit_bin/ListData.svc/Projects(4)/BudgetHours

35 35 REST (OData) APIs 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 Durban'

36 36 REST (OData) APIs Syntax: /_vti_bin/ListData.svc/{Entity}?$expand={Entity} Example to get a Project and its related Client: /_vit_bin/ListData.svc/Projects?$expand=Client

37 37 REST (OData) APIs $filter={simple predicate} $expand={Entity} $orderby={property} $skip=n $top=n $metadata See: http://msdn.microsoft.com/en-us/library/cc907912.aspx

38 38

39 39 Overview / Summary Much easier than before (asmx only) asmx web services still there if we need them Not limited to defined API Supports all client types Strongly Typed More Tooling Open standards-based

40 40 Data Technologies in SharePoint 2010 SharePoint 2010 List Data Model Relationships, Joins, and Data Integrity LINQ to SharePoint, Client OM Simple and integrated developer experience for list based Data Applications WCF & REST (OData) APIs Simplified and standardized model for when you need it

41 41 Data Access Technologies - Decision Matrix

42 42 Resources The Moss Show - http://www.TheMossShow.comhttp://www.TheMossShow.com http://sharepoint.microsoft.com SharePoint Developer Center – http://msdn.microsoft.com/sharepoint http://msdn.microsoft.com/sharepoint SharePoint Tech Center – http://technet.microsoft.com/sharepoint http://technet.microsoft.com/sharepoint Official SharePoint Team Blog – http://blogs.msdn.com/sharepoint http://blogs.msdn.com/sharepoint Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub.

43 43 (WTB305) Panel Discussion: Ask the experts about SharePoint (OFC423) Developing a BCS External Content Type with Visual Studio 2010 Related Content

44 44 Resources www.microsoft.com/teched www.microsoft.com/learning http://microsoft.com/technet http://microsoft.com/msdn SMS [ Your Name ] and the word Office to 41491 Need more Information?

45

46 © 2008 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.


Download ppt "Hilton Giesenow - The MOSS Show Developing with LINQ, REST & the New Client OM in Microsoft SharePoint 2010 SESSION CODE: OFC322."

Similar presentations


Ads by Google