SHAREPOINT 2010
CLIENT SIDE OBJECT
MODEL
Phil Wicklund
SharePoint FREEWARE
www.PhilWicklund.com
SharePoint CONSULTING
www....
About Me?
Training & Certifications:
• MCTIP: SharePoint 2010 Administration
• MCPD: SharePoint 2010 Development
• Microso...
Agenda
 Introduction / Why COM?
 COM Architecture
 Coding Samples
 DEMO
 .NET COM
 Questions
SharePoint FREEWARE
www...
Intro to the SP 2010 COM
 Not enough web services in SP 2007
 Rather than create more services, COM
provides the complet...
COM Architecture
SharePoint FREEWARE
www.PhilWicklund.com
SharePoint CONSULTING
www.RBAconsulting.com
Assembly References
 SharePoint, Server Side
 Microsoft.SharePoint (ISAPI)
 .NET clients
 Microsoft.SharePoint.Client ...
Comparable Objects
Microsoft.SharePoint Client Object Models
SPContext ClientContext
SPSite Site
SPWeb Web
SPList List
SPL...
Starter Code
Using Microsoft.SharePoint.Client;
...
using (ClientContext context = new
ClientContext("http://intranet"))
{...
Iterating through Lists in a Web
using (ClientContext context = new
ClientContext("http://intranet"))
{
Web web = context....
Efficiencies… Don’t be Lazy!
Web web = context.Web;
context.Load(web, wprop => wprop.Title));
ListCollection lists = web.L...
Working with List Items
Web web = context.Web;
List list = context.Web.Lists.
GetByTitle(“List Title");
CamlQuery query = ...
Efficencies with List Items
CamlQuery query = new CamlQuery();
query.ViewXml = "<View><Query><Where><Eq>
<FieldRef Name='T...
Adding new List Items
List list = context.Web.Lists.
GetByTitle(“List Title");
context.Load(list);
ListItem newItem = list...
Silverlight & Asynchronous Calls
private void Button_Click(object sender, RoutedEventArgs e)
{
// Load a bunch of stuff
cl...
.NET – COM Demo
 Build a Console (client) Application
 Render all the
List Titles from a remote
SharePoint site.
 Creat...
QUESTIONS & COMMENTS
Phil Wicklund
SharePoint FREEWARE
www.PhilWicklund.com
SharePoint CONSULTING
www.RBAConsulting.com
Upcoming SlideShare
Loading in...5
×

SharePoint 2010 Client-side Object Model

2,894

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,894
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "SharePoint 2010 Client-side Object Model"

  1. 1. SHAREPOINT 2010 CLIENT SIDE OBJECT MODEL Phil Wicklund SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  2. 2. About Me? Training & Certifications: • MCTIP: SharePoint 2010 Administration • MCPD: SharePoint 2010 Development • Microsoft’s SharePoint Masters Training (Redmond, WA) Other Notable Experience: • Published Author on SharePoint 2010 (SharePoint 2010 Workflows in Action) • National Speaker at SharePoint Conferences (The Experts Conference-LA, SharePoint Technology Conference-San Fran, TechFuse-MN, SharePoint Saturdays) • SharePoint Blog: www.philwicklund.com About Me: Over 6 years of experience SharePoint Architecture Experience, trained SharePoint architecture and development classes for nationally renown SharePoint- focused training organization.
  3. 3. Agenda  Introduction / Why COM?  COM Architecture  Coding Samples  DEMO  .NET COM  Questions SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  4. 4. Intro to the SP 2010 COM  Not enough web services in SP 2007  Rather than create more services, COM provides the complete API  COM provides a consistent development experience:  Windows Applications  ASP.NET web sites  Silverlight Applications  JavaScript, www client side scripting SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  5. 5. COM Architecture SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  6. 6. Assembly References  SharePoint, Server Side  Microsoft.SharePoint (ISAPI)  .NET clients  Microsoft.SharePoint.Client (ISAPI)  Silverlight clients  Microsoft.SharePoint.Client.Silverlight (Layouts/clientbin)  Javascript clients  SP.js & SP.Core.js (Layouts)SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  7. 7. Comparable Objects Microsoft.SharePoint Client Object Models SPContext ClientContext SPSite Site SPWeb Web SPList List SPListItem ListItem SPField Field SPFile File SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  8. 8. Starter Code Using Microsoft.SharePoint.Client; ... using (ClientContext context = new ClientContext("http://intranet")) { Web web = context.Web; context.Load(web); context.ExecuteQuery(); string title = web.Title; // ListCollection lists = web.Lists; } SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  9. 9. Iterating through Lists in a Web using (ClientContext context = new ClientContext("http://intranet")) { Web web = context.Web; context.Load(web); context.Load(web.Lists); context.ExecuteQuery(); foreach(List list in web.Lists) { //do something } } SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  10. 10. Efficiencies… Don’t be Lazy! Web web = context.Web; context.Load(web, wprop => wprop.Title)); ListCollection lists = web.Lists; IEnumerable<List> filtered = context. LoadQuery(lists.Include(l=>l.Title)); context.ExecuteQuery(); foreach(List list in filtered) { } SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  11. 11. Working with List Items Web web = context.Web; List list = context.Web.Lists. GetByTitle(“List Title"); CamlQuery query = CamlQuery.CreateAllItemsQuery(); ListItemCollection items = lst.GetItems(query); context.Load(items); context.ExecuteQuery(); foreach (ListItem item in items) { string title = item["Title"]; } SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  12. 12. Efficencies with List Items CamlQuery query = new CamlQuery(); query.ViewXml = "<View><Query><Where><Eq> <FieldRef Name='Title'/><Value Type='Text'>Phil</Value> </Eq></Where></Query></View>"; ListItemCollection items = list.GetItems(query); context.Load(items, x => x.Include( item => item["ID"], item => item["Title"], item => item.DisplayName)); SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  13. 13. Adding new List Items List list = context.Web.Lists. GetByTitle(“List Title"); context.Load(list); ListItem newItem = list.AddItem(new ListItemCreationInformation()); newItem["Title"] = "My new item"; newItem.Update(); context.ExecuteQuery(); SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  14. 14. Silverlight & Asynchronous Calls private void Button_Click(object sender, RoutedEventArgs e) { // Load a bunch of stuff clientContext.ExecuteQueryAsync(success, failure); } private void success(object sender, ClientRequestSucceededEventArgs args) { RunQuery runQuery= Run; this.Dispatcher.BeginInvoke(runQuery); } private delegate void RunQuery(); private void Run() { /* do something */ } private void failure(object sender, ClientRequestFailedEventArgs args) { /* do something */ } SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  15. 15. .NET – COM Demo  Build a Console (client) Application  Render all the List Titles from a remote SharePoint site.  Create a new list item in a remote SharePoint site. SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAconsulting.com
  16. 16. QUESTIONS & COMMENTS Phil Wicklund SharePoint FREEWARE www.PhilWicklund.com SharePoint CONSULTING www.RBAConsulting.com

×