Developing With Data TechnologiesChakkaradeep Chandranhttp://www.chakkaradeep.com@chakkaradeep
Session Objectives and TakeawaySession Objectives:Explain SharePoint Data TechnologiesPresent the new List Platform CapabilitiesDemonstrate how to interact with SharePoint data using:LINQ to SharePointClient Object Model.NET CLRSilverlight CLRJavaScript CLRRESTful Data Service InterfaceTakeaway:Building applications using the various SharePoint 2020 Data Technologies
SharePoint 2010 for DevelopersVisual Studio 2010Install on Windows 7SharePoint Designer 2010Developer DashboardDeveloper ProductivityBusiness Connectivity Services LINQ, REST and Data ImprovementsClient Object ModelSilverlight Web PartECMAScript Object Model (JavaScript,JSCript)Rich Platform ServicesTeam Foundation ServerSandboxed SolutionsWSP Solution UpgradeSharePoint OnlineFlexible Deployment
Overview of Data TechnologiesREST APIsClient OMClient SideData PlatformServer SideFarmSiteList DataExternal ListsLINQ(spmetal.exe)ServerOM
List Data Improvements in SharePoint 2010
Lists and LookupsLookupLookupProjectsEmployeesClientsm1m1Lookups form relationships between listsOne-to-manyMany-to-many
List RelationshipsEnforce Data IntegrityOne-to-many relationships can be used to:Trigger cascade deleteRestrict deleteRelationship behaviors (delete/restrict) are not supported on multi-value lookups
List ValidationValidation 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])
Large ListsSet a limit for how many rows of data can be retrieved for a list or library at any one time:List View ThresholdList View Threshold for Auditors and AdministratorsList View Lookup ThresholdDaily Time Window for Large QueriesIf enabled on the Web Application, developer can turn off throttling using:SPQuery.RequestThrottleOverrideSPSiteDataQuery.RequestThrottleOverride
List View Threshold
List Data ModelLookup to Multiple ColumnsList RelationshipsRelated Items UIList Validation
Summary : List Data ImprovementsREST APIsClient OMClient SideData PlatformServer SideFarmSiteList DataExternal ListsLINQ(spmetal.exe)ServerOM
Server ObjectModel
Building Server Applications.aspx.csServer OMSharePoint dataSharePoint dataClasses & ObjectsSharePoint Site
Server Object Model Example CodeUsing 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 }
LINQ to SharePoint(SPLinq)
LINQ to SharePointEntity based programmingStrong Types and IntellisenseTranslates LINQ queries to CAML queriesSupports List Joins and ProjectionsJoin lists on lookup field between themJoin multiple lists (A->B->C)Project any field from joined list in a query without              changes in list schemaCan be used inWeb PartsEvent ReceiversSandboxed Code
LINQ to SharePoint Basicsspmetal.exeSPLinq.csSPLinq.vbspmetal/web:http://dataetch/code:SPLinq.csSharePoint Sitehttp://datatechSPLinqDataContextSPLinqDataContext 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;
SPMetal Options
LINQ to SharePoint
SPMetal – Default Code Generation Rulesspmetal.exeSPLinqDataContextProjectProjectsClassPropertyGetProjects
SPMetal Parameters XML FileSPMetal does not require a parameters XML fileTo 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>
LINQ to SharePoint: Parameters XML File
Summary : LINQ to SharePointREST APIsClient OMClient SideData PlatformServer SideFarmSiteList DataExternal ListsLINQ(spmetal.exe)ServerOM
Client ObjectModel
Building Client Applications – MOSS 2007{code}Web Services{SharePoint  data}SharePoint SiteSharePoint API{SharePoint data}
Client Object Model – SharePoint 2010{code}{SharePoint data}Client Object Model{SharePoint data}SharePoint Site
Client Object Model Example Codeclass 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); } }
Client OM
Client Object Model – How It WorksWCF Service(Client.svc)JavaScript ApplicationServer OMJSON ResponseJavaScript OMSharePoint SiteXML RequestProxyXML RequestProxyJSON ResponseManaged OMManaged Code Application (.NET)
Client Object Model – How It WorksClient ApplicationServerSequence of commands:command 1;command 2;command 3;context.ExecuteQuery();client.svcExecute commandsin the batch:command 1;command 2;command 3;Send results backXMLJSONProcess results
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
Client Object Model – The PatternCreate a Client ConnectionCreate the QueryExecute the QueryClientContextclientContext = new ClientContext("http://datatech");clientContext.ExecuteQuery();List list = clientContext.Web.Lists.GetByTitle(“Projects");clientContext.Load(list);
Client Object Model – Trimming the ResultsTitlePropertyWebSharePoint SiteListsCollectionTitlePropertyIdProperty
.NET CLR Client Object ModelRequires two assemblies:Microsoft.SharePoint.ClientMicrosoft.SharePoint.Client.RuntimeDevelop solutions remotely
.NET Client OMUsing CAML QueryObject IdentityTrimming The ResultsCreating and Populating a ListUpdating Client ObjectsDeleting Client ObjectsAsynchronous Pattern
Silverlight CLR Client Object ModelRequires two assemblies:Microsoft.SharePoint.Client.SilverlightMicrosoft.SharePoint.Client.Silverlight.RuntimeDevelop solutions remotely
Silverlight Client OM
JavaScript Client Object ModelMinified .js files for the ECMAScript (JavaScript, JScript) object model:SP.jsSP.Core.jsSP.Ribbon.jsSP.Runtime.jsBrowser Support for ECMA Script:Microsoft Internet Explorer 7  and greaterFirefox 3.5 and greaterSafari 4.0 and greaterDevelop solutions remotely
JavaScript Client OM
Summary : Client Object ModelREST APIsClient OMClient SideData PlatformServer SideFarmSiteList DataExternal ListsLINQ(spmetal.exe)ServerOM
RESTful Data ServiceInterface
RESTful Data Service InterfaceREST-style list data web servicehttp://<site>/_vti_bin/ListData.svcWork with data via RESTSharePoint List DataPowered by ADO.NET Data ServicesADO.NET Data Services v1.5 CTP2Entity based programmingStrong TypesLINQ QueriesIntegration with Visual Studio
REST API QueryString Parameters$filter={simple predicate}$expand={Entity}$orderby={property}$skip=n$top=n$metadataFull List - http://bit.ly/RESTfulAPI
Makes Development Easy!
Accessing List Data via REST APIs
SummaryREST APIsClient OMClient SideData PlatformServer SideFarmSiteList DataExternal ListsLINQ(spmetal.exe)ServerOM
Thank Youchaks@intergen.co.nzhttp://www.chakkaradeep.com/category/SharePoint-2010.aspxhttp://twitter.com/chakkaradeep

Developing With Data Technologies

  • 1.
    Developing With DataTechnologiesChakkaradeep Chandranhttp://www.chakkaradeep.com@chakkaradeep
  • 2.
    Session Objectives andTakeawaySession Objectives:Explain SharePoint Data TechnologiesPresent the new List Platform CapabilitiesDemonstrate how to interact with SharePoint data using:LINQ to SharePointClient Object Model.NET CLRSilverlight CLRJavaScript CLRRESTful Data Service InterfaceTakeaway:Building applications using the various SharePoint 2020 Data Technologies
  • 3.
    SharePoint 2010 forDevelopersVisual Studio 2010Install on Windows 7SharePoint Designer 2010Developer DashboardDeveloper ProductivityBusiness Connectivity Services LINQ, REST and Data ImprovementsClient Object ModelSilverlight Web PartECMAScript Object Model (JavaScript,JSCript)Rich Platform ServicesTeam Foundation ServerSandboxed SolutionsWSP Solution UpgradeSharePoint OnlineFlexible Deployment
  • 4.
    Overview of DataTechnologiesREST APIsClient OMClient SideData PlatformServer SideFarmSiteList DataExternal ListsLINQ(spmetal.exe)ServerOM
  • 5.
    List Data Improvementsin SharePoint 2010
  • 6.
    Lists and LookupsLookupLookupProjectsEmployeesClientsm1m1Lookupsform relationships between listsOne-to-manyMany-to-many
  • 7.
    List RelationshipsEnforce DataIntegrityOne-to-many relationships can be used to:Trigger cascade deleteRestrict deleteRelationship behaviors (delete/restrict) are not supported on multi-value lookups
  • 8.
    List ValidationValidation Formulacan 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 ListsSet alimit for how many rows of data can be retrieved for a list or library at any one time:List View ThresholdList View Threshold for Auditors and AdministratorsList View Lookup ThresholdDaily Time Window for Large QueriesIf enabled on the Web Application, developer can turn off throttling using:SPQuery.RequestThrottleOverrideSPSiteDataQuery.RequestThrottleOverride
  • 10.
  • 11.
    List Data ModelLookupto Multiple ColumnsList RelationshipsRelated Items UIList Validation
  • 12.
    Summary : ListData ImprovementsREST APIsClient OMClient SideData PlatformServer SideFarmSiteList DataExternal ListsLINQ(spmetal.exe)ServerOM
  • 13.
  • 14.
    Building Server Applications.aspx.csServerOMSharePoint dataSharePoint dataClasses & ObjectsSharePoint Site
  • 15.
    Server Object ModelExample CodeUsing 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 }
  • 16.
  • 17.
    LINQ to SharePointEntitybased programmingStrong Types and IntellisenseTranslates LINQ queries to CAML queriesSupports List Joins and ProjectionsJoin lists on lookup field between themJoin multiple lists (A->B->C)Project any field from joined list in a query without changes in list schemaCan be used inWeb PartsEvent ReceiversSandboxed Code
  • 18.
    LINQ to SharePointBasicsspmetal.exeSPLinq.csSPLinq.vbspmetal/web:http://dataetch/code:SPLinq.csSharePoint Sitehttp://datatechSPLinqDataContextSPLinqDataContext 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;
  • 19.
  • 20.
  • 21.
    SPMetal – DefaultCode Generation Rulesspmetal.exeSPLinqDataContextProjectProjectsClassPropertyGetProjects
  • 22.
    SPMetal Parameters XMLFileSPMetal does not require a parameters XML fileTo 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>
  • 23.
    LINQ to SharePoint:Parameters XML File
  • 24.
    Summary : LINQto SharePointREST APIsClient OMClient SideData PlatformServer SideFarmSiteList DataExternal ListsLINQ(spmetal.exe)ServerOM
  • 25.
  • 26.
    Building Client Applications– MOSS 2007{code}Web Services{SharePoint data}SharePoint SiteSharePoint API{SharePoint data}
  • 27.
    Client Object Model– SharePoint 2010{code}{SharePoint data}Client Object Model{SharePoint data}SharePoint Site
  • 28.
    Client Object ModelExample Codeclass 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); } }
  • 29.
  • 30.
    Client Object Model– How It WorksWCF Service(Client.svc)JavaScript ApplicationServer OMJSON ResponseJavaScript OMSharePoint SiteXML RequestProxyXML RequestProxyJSON ResponseManaged OMManaged Code Application (.NET)
  • 31.
    Client Object Model– How It WorksClient ApplicationServerSequence of commands:command 1;command 2;command 3;context.ExecuteQuery();client.svcExecute commandsin the batch:command 1;command 2;command 3;Send results backXMLJSONProcess results
  • 32.
    ClientContextclientContext= new ClientContext("http://sptechcon");Listlist= 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 PatternCreate a Client ConnectionCreate the QueryExecute the QueryClientContextclientContext = new ClientContext("http://datatech");clientContext.ExecuteQuery();List list = clientContext.Web.Lists.GetByTitle(“Projects");clientContext.Load(list);
  • 34.
    Client Object Model– Trimming the ResultsTitlePropertyWebSharePoint SiteListsCollectionTitlePropertyIdProperty
  • 35.
    .NET CLR ClientObject ModelRequires two assemblies:Microsoft.SharePoint.ClientMicrosoft.SharePoint.Client.RuntimeDevelop solutions remotely
  • 36.
    .NET Client OMUsingCAML QueryObject IdentityTrimming The ResultsCreating and Populating a ListUpdating Client ObjectsDeleting Client ObjectsAsynchronous Pattern
  • 37.
    Silverlight CLR ClientObject ModelRequires two assemblies:Microsoft.SharePoint.Client.SilverlightMicrosoft.SharePoint.Client.Silverlight.RuntimeDevelop solutions remotely
  • 38.
  • 39.
    JavaScript Client ObjectModelMinified .js files for the ECMAScript (JavaScript, JScript) object model:SP.jsSP.Core.jsSP.Ribbon.jsSP.Runtime.jsBrowser Support for ECMA Script:Microsoft Internet Explorer 7 and greaterFirefox 3.5 and greaterSafari 4.0 and greaterDevelop solutions remotely
  • 40.
  • 41.
    Summary : ClientObject ModelREST APIsClient OMClient SideData PlatformServer SideFarmSiteList DataExternal ListsLINQ(spmetal.exe)ServerOM
  • 42.
  • 43.
    RESTful Data ServiceInterfaceREST-style list data web servicehttp://<site>/_vti_bin/ListData.svcWork with data via RESTSharePoint List DataPowered by ADO.NET Data ServicesADO.NET Data Services v1.5 CTP2Entity based programmingStrong TypesLINQ QueriesIntegration with Visual Studio
  • 44.
    REST API QueryStringParameters$filter={simple predicate}$expand={Entity}$orderby={property}$skip=n$top=n$metadataFull List - http://bit.ly/RESTfulAPI
  • 45.
  • 46.
    Accessing List Datavia REST APIs
  • 47.
    SummaryREST APIsClient OMClientSideData PlatformServer SideFarmSiteList DataExternal ListsLINQ(spmetal.exe)ServerOM
  • 48.

Editor's Notes

  • #5 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
  • #7 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.
  • #8 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