An Odyssey Into the SharePoint 2010 Development World
Nik Patel
Lead Solutions Architect, Slalom Consulting, Chicago Practice
About Me
Nik Patel • Lead Solutions Architect, Slalom Consulting
• Working with SharePoint 2010 since Summer 2009
• Working with SharePoint since SharePoint 2003 days
Contact Info • Email – [email protected]
• Blog – Nik Patel’s SharePoint World -
http://nikspatel.wordpress.com/
• Twitter - @nikxpatel
• LinkedIn - linkedin.com/in/nikspatel
• Slideshare - slideshare.net/patenik2
2
Session Goals Setting stage for future sessions
This is introductory session
Provides sweeping overview of features, No deep dives, Get ready for fast ride
Focus on both entry-level and experienced SharePoint developers
Setting stage for future deep dive sessions
Lots of practical tips and lessons I have learned from last 3 years of SharePoint 2010 product lifecycle
Provide 1000 ft. view of SharePoint Development landscape in 1 Hour.. It’s tricky but not impossible.
3
Session Agenda Nik’s 6 Steps into SharePoint Development Nirvana
Step 1 - Understanding SharePoint Developer Role
Step 2 - Understanding & Configuring SharePoint 2010 Development Environment
Step 3 - Understanding Core SharePoint 2010 Development Concepts
Step 4 - Understanding Visual Studio Tooling Support (SP2010 Developer Productivity)
Step 5 - Developing SharePoint 2010 Building Blocks and Artifacts
Step 6 - Understanding of SharePoint 2010 Data Access Strategies
Questions and Answers
4
Step 1 – Nik’s 6 Steps into SharePoint Development Nirvana
Understanding SharePoint Developer Role
5
Anatomy of SharePoint Developer Role It is demanding, because SharePoint will challenge you like you never been
SharePoint Developer is very complex role SharePoint Developer should be proper End User Understand SharePoint OOB Capabilities
SharePoint Developer should be strong Power User Understand Browser Customization and No-Code Solutions
SharePoint Developer should be efficient Administrator Understand how SharePoint Farm, Web Application, Site Collection, and Service Application Infrastructure Configured
SharePoint Developer should be true programming rock star. Understand and make decision on what kind of custom artifacts and data access strategies can be designed on SharePoint Platform
Be ready to work with wide varieties of languages and frameworks (e.g. C#, SQL, javaScript/jQuery, AJAX, WCF etc.)
Always keep in mind - SharePoint is Packaged Product SharePoint is Platform and understanding it’s capabilities and limitations are important
6
Typical SharePoint Developer Life – Day to Day Activities Extending SharePoint Platform
Provision SharePoint Artifacts Site Columns, Site Content Types, Lists, Web Parts, Workflows, Pages, Sites, Timer Jobs etc.
Build Business Applications based on SharePoint Platform Accessing SharePoint 2010 Data from SharePoint itself like Lists or Sites Data in Web Parts
Accessing LOB or External Data in SharePoint like CRM, SAP, SQL
Accessing SharePoint Data from Remote External Systems like Standalone ASP.NET, Standalone Silverlight, Console Utilities, CRM Systems etc.
Perform Advanced SharePoint Development User Profiles Provisioning, Search API, Managed Metadata Maintenance
Solution Packaging and Deployment PowerShell Scripting for Solutions and Features deployment, upgrade, and maintenance
Application Life Cycle Management using Automatic Build and TFS integration
7
Step 2 – Nik’s 6 Steps into SharePoint Development Nirvana
Understanding & Configuring SharePoint 2010 Development Environment
8
Configure SharePoint 2010 Development Environment Every SharePoint developer should have at least 1 development environment
Either install directly on metal or use Virtual machines My preference is VM – more flexible, I use VMware workstation on Windows 7 x64 Host
SharePoint 2010 requires x64 Operating System and Database Servers Windows 7, Windows Vista SP1, Windows Server 2008, or Windows Server 2008 R2
SQL Server 2012, SQL Server 2008 R2, SQL Server 2008 with SP1 and CU2, SQL Server 2005 with SP3 and CU3
SharePoint 2010 must be installed locally on Developer Machine SharePoint Foundation or SharePoint Server (RTM or SP1 with latest CU)
Requires Single Server Farm Installation
Not Supported for Production or Multi-Server farm – SQL and AD can be installed on separate machine
Based on .NET Framework 3.5 and ASP.NET 3.5 - Installed as SharePoint 2010 Pre-requisites
Visual Studio 2010 (RTM or SP1) and SharePoint Designer 2010 Visual Studio 2010 SharePoint Power Tools – Provides Sandboxed Visual Web Part template
Use Visual Studio 2012 as soon as it’s in RTM, Lot more improvements for SP2010 development
9
Step 3 – Nik’s 6 Steps into SharePoint Development Nirvana
Understanding Core SharePoint 2010 Development Concepts
10
SharePoint Terminology Overwhelming at first, steep learning curve, ever-changing landscape, lifetime to master
Farm Solutions
Feature
Solution Package
Event Receiver
Web Application
Site Definition
Feature Receiver
PowerShell
Workflows
Client Object Model
Timer Job
List Definition
List Instance
Content Type
Web Templates
Site Collection
Custom Actions
Safe Control
Feature Scope
Ribbon Framework Publishing Layouts
Field Control Document Libraries Team Site
Site Pages
Understanding SharePoint Object Hierarchy Server Side Object Model
Object Hierarchy (Top to Bottom) Object Hierarchy (Bottom to Top)
12
SharePoint Hierarchy
Farm
Web Application(s)
Site Collection(s)
Site(s)
List(s)
List Item(s)
SPFarm
SPWebApplication (SPWebApplication.Sites)
SPSite (SPSite.AllWebs)
SPWeb (SPWeb.Lists)
SPList (SPList.Items)
SPListItem
SPFarm
SPWebApplication (SPWebApplication.Farm)
SPSite (SPSite.WebApplication)
SPWeb (SPWeb.Site)
SPList (SPList.ParentWeb)
SPListItem (SPListItem.ParentList)
What is Solutions and Features Framework? Building blocks of SharePoint Development, Packaging, and Deployment
Features
Deployed in {SP Root}\TEMPLATE\FEATURE
Features are the basic building block of SharePoint development
Features may be comprised of any combination of code or artifacts including web parts or workflows
Features may be activated manually or automatically on a local or global basis
Features are scoped at Farm, Web Application, Site Collection, and Web Level
13
Solutions - WSPs
Deployed in Farm Solutions or Sandbox Solutions in Site Collections Solutions Gallery
Solution Packages are “bundles” of functionality deployed to the farm or site collection
May contain one or more Features, assemblies, pages, controls, and other artifacts
SharePoint framework handles installation and configuration of solution items automatically across entire farm
Sandbox vs. Farm Level Solutions Execution environment during runtime
Farm Level Solutions
Also known as Full Trust Solutions
Deployed to Farm Solutions Gallery by Farm Administrators
Runs inside IIS Worker Process (W3WP.exe) for specific web application
Stored in the SharePoint Configuration Database
Farm level solutions requires SharePoint Foundation Web Application Service started on the farm.
Farm level solutions not restricted to any data access
Farm level solutions are not restricted to resource quotas and code will run until IIS worker process terminates by itself
14
Sandbox Solutions
Also Known as User Solutions
Deployed to Site Collection Solution Gallery by Site Collection Administrators
Runs inside Application domain per site collection in the Sandbox Worker Process (SPUCWorkerProcess.exe)
Stored in the Site Collection Content Database
Sandbox solutions requires Microsoft SharePoint Foundation Sandboxed Code Service started on the farm.
Sandbox solutions runs using restrictive code access security policies and limited to a specific subset of SharePoint 2010 object model – Major limitations are not able to access database, file system, RSS feeds, web services, cross-site collection, farm and web application scoped features, running with elevated privileges
Sandbox solutions runs under resource quota and exceeding resource quota with irresponsible code will terminate the process
Typical SharePoint Solution Deployment, Upgrade, and Retraction Process Use Visual Studio, Central Administration, or PowerShell for Deployment and Retraction
15
Farm
Web Application
Site Collection
Web
Solutions Gallery
Typical Deployment Sequence 1. Add Solution 2. Deploy Solution 3. Activate Features
i. Farm ii. Web Application(s) iii. Site Collection(s) iv. Web(s)
4. Update Solution (Upgrade)
Typical Retraction Sequence 1. Deactivate Features
i. Web(s) ii. Site Collection(s) iii. Web Application(s) iv. Farm
2. Retract Solution 3. Remove Solution
Please note that Adding and Updating Solution is not supported in Central Administration site.
Step 4 – Nik’s 6 Steps into SharePoint Development Nirvana
Understanding Visual Studio Tooling Support
16
Getting Started – Initial SharePoint 2010 Project Setup Understand Visual Studio Tooling Support
VS2010 with SharePoint 2010
Works Perfect Together - Build, Debug, Deploy, and Package
Project Templates
Empty SharePoint Project, Import from Solution Package
Item Templates
Visual Web Part, Web Part, Workflow, BDC Model, Application Page, Event Receiver, Module, Content Type, List Definition, Empty Element
Visual Designers
BCS Model, Visual Web Parts, Workflows in Visual Studio 2010
New in Visual Studio 2012 RC
Much better organization of project templates and item templates- removed unnecessary project templates
Added Content Type and List Designer (2010 requires CAML coding)
Added Site Column and Silverlight Web Part Item Template
17
Getting Started – Project Packaging and Maintenance Understand Visual Studio Tooling Support
Project Wizard
URL where you want to deploy
Farm vs. Sandbox Solution Deployment
Project System
Solution Explorer - Deploy, Retract, and Package
Project Properties - Site URL, Sandboxed Solution etc.
Mapped Folders – SharePoint Root
Feature and Package Designer
Generate WSP for Production Deployment
Server Explorer - SharePoint Site Collection Connections from Visual Studio
Hierarchical view of local SharePoint sites & artifacts
View SharePoint site collections, sites, features, lists, site columns etc
TFS and Source Control Integration
18
Demo
19
Walkthrough of Hello World Web Part in Visual Studio
What really happens when you deploy farm solution?
Reference Card – What really happens when you deploy farm solution? Understanding what really happens under the hood is key
Areas affected by Solutions Deployment
SharePoint Configuration Database, Objects Table
Web Application Content Databases, Features Table
Central Administration, Solutions Gallery
File System - SP Root Folder
GAC - Global Assemblies Gallery
Web Application Web.config files
Activate Site Collection or Site Features
Site Collection Galleries like Web Parts or Master Pages or file provisioned in content databases
20
For More info - http://nikspatel.wordpress.com/2011/12/05/behind-the-screen-what-really-happens-during-solution-deploymentretraction-feature-activationdeactivation-process/
Step 5 – Nik’s 6 Steps into SharePoint Development Nirvana
Developing SharePoint 2010 Building Blocks and Artifacts
21
Developing SharePoint Artifacts Extending SharePoint Deployment through CAML or Platform APIs
Common Artifacts
Site Columns, Site Content Types, Field Types
List definition and List Instances
Event Receivers
Site Pages/Web Part Pages, and Application Pages
Web Parts & Visual Web Parts
Workflows
Site Definition, Web Templates, and Site Provisioning Process
Custom Actions, Ribbon and Dialog Framework
Typically Three Approaches for Provisioning SharePoint Artifacts
CAML Approach using Feature.xml and Elements.xml
Programmatic Approach using Feature Receiver
Programmatically Provisioning components using C# or PowerShell
22
Demo
23
• Provision List Definition and List Instance
Step 6 – Nik’s 6 Steps into SharePoint Development Nirvana
Overview of SharePoint 2010 Data Access Strategies
24
SharePoint Data Access Strategies Three Common Design Patterns
Accessing SharePoint Data from SharePoint itself
Accessing data from Current Site Collection, Cross-Site Collection, Cross-Web Application, or Cross-Farm
Many options to choose from - SSOM, LINQ to SharePoint, CSOM, REST based API, ASMX Web Services, Custom WCF Services, Search APIs etc.
Accessing External Data from SharePoint
Accessing LOB or External Data in SharePoint like CRM, SAP, SQL, etc.
Many Options to choose from - LINQ-to-SQL, ADO.NET, Entity Framework, Web Services Interface, or SharePoint Preferred method BCS for Platform Integration
Accessing SharePoint Data from Remote Systems
Accessing SharePoint Data from Remote External Systems like Standalone ASP.NET, Standalone Silverlight, Console Utilities, CRM Systems etc.
Many Options to choose from - CSOM, REST based API, ASMX Web Services, Custom WCF Services etc.
25
Overview of SharePoint 2010 Data Technologies Understanding both Client side and Server side API is key
26
Farm Site List Data External Lists
Client OM
REST APIs
ASMX Web Services
Making decision – Questions you should ask yourself Understanding what really happens under the hood is key
How will your code will be deployed?
Farm solution or sandboxed solution or non-SharePoint solutions
How important is developer productivity?
Are IntelliSense, Compile time errors, and strongly-typed access important?
Where will your code run?
Server-side code or client-side code
Within SharePoint, .NET Applications like Silverlight or CRM, Non.NET Applications like Java or JavaScript
What is the scope of your code to run?
Same Site, Same Site Collection, Cross-Site Collection, Cross-Web Application, Cross-farm
How many items your query will return?
5 items or 500 items or 5,000 items or 50,000 items
27
Overview of Server Side Data Access Technologies Both Options Must Run on the SharePoint Servers
Server Side Object Model – SPQuery and SPDataQuery
• SPQuery executes query against single list or performs join with on multiple lists on lookup columns with in site collection
• SPDataQuery executes query against multiple lists to aggregate results, scoped at site collection level.
• SPQuery uses CAML fragments and access to columns is not strongly typed - hard coded column names, quirky syntax, lack of tooling support, and difficult debugging
• CAML provides fastest way to access data, must be used in high performing applications
LINQ-to-SharePoint
Executes query against single list or performs join on multiple lists on lookup columns with in site collection, You can’t aggregate multiple lists data without lookup column
Microsoft supplies spmetal.exe to generate LINQ to SharePoint entities, Needs to regenerate the entities if List Schema changes
Strongly typed entities to perform CRUD operations against SharePoint data
High productivity, IntelliSense, and less error-prone programming
Translates into CAML query during runtime, little performance overhead, 5-10% slower than SPQuery
28
Comparing SharePoint 2010 Server Side Data Technologies Decision Making Process
SPQuery SPDataQuery LINQ to SharePoint
Querying SharePoint list data within a site X X
Using joins on SharePoint lists within a site X X
Using joins on SharePoint list data across sites within a site collection X X
Aggregating list data across multiple sites within a site collection X
Querying external list data within a site X
Strongly typed data access, IntelliSense Support, and High
Productivity (Requires leaning of LINQ) X
High performance & faster queries (Requires learning of CAML) X X
Error prone coding - hard coded column names, quirky syntax, lack of
tooling support, and difficult debugging X X
Needs to regenerate the data context classes if schema changes X
29
Reference - More Info - http://msdn.microsoft.com/en-us/library/ff798432
Overview of Client Side Data Access Technologies Avoid these options running on the SharePoint Servers unless Cross-farm situations or Office 365 limitations
Client Side Object Model – WCF Service - Client.svc
• Three different Models - .NET Managed, Silverlight, ECMAScript
• Subset of server OM functionality but similar APIs, Can’t access data outside of current site collection
• CSOM executes query against single list or performs join on multiple lists on lookup columns with in site collection
Allows submitting CAML queries directly from client side logic, same restrictions as SPQuery - Fastest option but error prone coding
REST API - WCF Data Services - ListData.svc
• REST is HTTP-based XML data transfer design pattern based on OData protocol - Stateless, cacheable, uniform
• Returns results in ATOM Feed or JSON format (For JS clients)
• Able to maintain & browse lists using HTTP verbs - GET, POST, PUT, DELETE, and MERGE
• Available for Lists (ListData.svc) and Excel Services REST API (ExcelRest.aspx)
• Client-side technique with strongly typed access, Intelligence Support, LINQ style productivity, Same restrictions as LINQ-to-SharePoint, Needs to refresh the proxy class if List Schema changes
Legacy ASP.NET SOAP based Web Services
Scoped at the List or Library level data access, requires custom web services for multiple list joins
Developer must parse CAML fragments and access to columns is not strongly typed
Supports advanced SharePoint Server capabilities like search, social, or user profile services, which are unavailable through the CSOM or REST APIs
30
Comparing SharePoint 2010 Client Side Data Technologies Decision Making Process
CSOM REST API ASMX Web Services
SharePoint Data Access Scope Site Collection List List
List Queries X X X
List Join Queries X
External List Queries X
Request Batching X X
Synchronous Operations X (Except ECMA) X
Asynchronous Operations X X X
SharePoint Foundation Object Model Access X
Access to SharePoint Server Functionality
(Social, User Profiles, and Search Data) X
Supports Non-Windows Clients X (ECMA only) X X
Supports Strongly Typed LINQ Queries X(objects only, no list queries) X (with proxy, lists only)
Requires CAML for List Data Access X X
Access from Sandbox Solutions X (SPServices Plugin)
31
Reference - More Info - http://msdn.microsoft.com/en-us/library/ff798473
Demo
32
• Accessing SharePoint List data using JavaScript CSOM
Advanced Data Access Technologies Enterprise Level Data Access Methods
Custom WCF Web Services
Extend out of box SharePoint functionality
Can be hosted in SharePoint, IIS, or any other .NET client
Ideal for third party vendors, ISVs, or enterprise system integration
Business Data Connectivity Services
New in SharePoint 2010, Replacing Business Data Catalog
Allows interface to external entities by implementing read-write interface to the external data by external content types and external list
Provides platform integration for external systems for secured data access and search
Useful alternative to access data from traditional manner like LINQ-to-SQL, ADO.NET, or Entity Framework
Enterprise Search API
This is Enterprise Search capability, not FAST Search
Perfect for Cross-farm, Cross-Web Application, or Cross-Site Collection Data Access
Greater scalability, All other techniques are mostly SQL-based, fast even large amount of data across multiple farms
Requires data must be in index, data must be tagged, and mapped to managed properties
33
What’s Next for you?
Practice, adhere, and master SharePoint development best practices
Here is the start - http://nikspatel.wordpress.com/2011/06/22/sharepoint-2010-development-best-practices/
Stay connected and Involved in Community – User Groups, Conferences, Webinars, Code fests
Stay active on Social Media
Follow Major MVPs and MSDN Blogs – Bookmark great articles
Follow MVPs and major SharePoint Community Players on Twitter and Facebook
Major Resources
SharePoint 2010 SDK - http://msdn.microsoft.com/en-us/library/ee557253.aspx
Patterns & Practices - Developing Applications for SharePoint 2010 - http://msdn.microsoft.com/en-us/library/ff770300
MSDN SharePoint Developer Center - http://msdn.microsoft.com/en-us/sharepoint/default.aspx
MSDN SharePoint 2010 Forums - http://social.msdn.microsoft.com/Forums/en-US/category/sharepoint2010
34
35
• Thanks for attending the session!! • Follow Chicago SharePoint Developers User Group
• Twitter - @ChDevSPUG
• Website - http://www.chdevspug.com/
Top Related