Download - Ep development best practices v.06
![Page 1: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/1.jpg)
Best Practices and Avoiding Common Errors with SharePoint DevelopmentIvan Sanders
SharePoint Architect
Microsoft SharePoint Server MVPDimension Solutions inc.
![Page 2: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/2.jpg)
Topics
Data accessSite objectsCross-site objects
Data aggregation SharePoint trivia Questions and Answers
![Page 3: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/3.jpg)
Data Access
Site Objects
![Page 4: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/4.jpg)
SharePoint Lists List data is stored in single UserInfo table for
each content database List constructs are virtualized and non-
relational (but you can create relationships programmatically)
Lists are optimized for UI not for transactional data access
Limited data types and data type instances
![Page 5: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/5.jpg)
SharePoint Lists
UserInfo TableList Views
Web Parts
Search Crawler
Alerts
Publishing Fields
![Page 6: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/6.jpg)
Data Retrieval
Use an indexer to return a
single list item from the
collection
![Page 7: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/7.jpg)
Data Retrieval
Use an indexer to return a
single list item from the
collection
![Page 8: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/8.jpg)
Data Retrieval
Looping operations in the object model are
very resource intensive
![Page 9: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/9.jpg)
Data Retrieval Design architecture to support
application requirements Use CAML queries for targeted item selection Maintain SQL indexes for optimal
query execution Manipulate item data using in-memory
objects (SPListItemCollection, DataTable, <List>, XML)
For extremely large data sets, segment data across multiple content databases
![Page 10: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/10.jpg)
Data Presentation 2000 item limit guideline applies only to built-in
list views NOT to list contents Extremely large list structures (10,000+ items)
require custom web parts to display content Data-bound objects provide best performance XML + XSLT outperforms list view objects Page results to reduce rendering times Beware caching of large data sets in
ViewState
![Page 11: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/11.jpg)
Web Services
Provide front-end for OM code Return list objects as XML Manipulating XML in memory is more
efficient than repeated calls OM Require extensive text manipulation Beware column name differences and
content formatting
![Page 12: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/12.jpg)
Web Services
SharePoint Emoticons (My Fav)
0;# SP sticking its tongue out (:-P) X0020
This_x0020_is_x0020_My_x0020_Favorite ows_ All Your Fields Are Belong to OWS -1001 Look! Booleans can be anything!
![Page 13: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/13.jpg)
Demo
Using SharePoint Lists as a Data Source
![Page 14: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/14.jpg)
Data Access
Cross-Site Objects
![Page 15: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/15.jpg)
CAML
No native cross-site functionality Combine with recursive methods to
create consolidated datasetRecurse list of site and list objects (XML,
Delimited, GetSubwebsForCurrentUser, etc.)
Store list items in ADO.NET object (DataTable, DataSet, etc.)
Be aware of memory issues when using SPQuery to retrieve very large datasets
![Page 16: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/16.jpg)
PortalSiteMapProvider MOSS only Optimized for repeated calls to same set
of objects Use the GetCachedListItemsByQuery()
method for cacheable items that do not change often
Executes CAML Query without having to walk the collection of SPWeb objects
List items must still be iterated using in-memory methods
![Page 17: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/17.jpg)
Search
Provides non-contextual item data within defined scope(s)
Requires parsing potentially large number of results (XML or ResultTable)
Scopes and queries must be managed to return desired results – no guarantee that default results will include the desired item(s)
Access to contextual item data requires recursive object methods
![Page 18: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/18.jpg)
Web Services Some methods provide multiple object
support (lists, Webs, etc.) Results are non-contextual; however, most
metadata is available in native methods Resultant XML must be parsed and
manipulatedXML may be consolidated and XPATH used in
place of recursion Extensive/repetitive calls increase overhead
on WFEs
![Page 19: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/19.jpg)
Demo
Retrieving SharePoint List Items from Multiple Site Collections using MOSS Search
![Page 20: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/20.jpg)
Data Aggregation
![Page 21: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/21.jpg)
Relational Data
SharePoint lists are inherently non-relational Structure in Lists tableData in UserInfo tableFixed number of field elements
Relationships must be created programmatically using combination of list definitions and ADO.NET, LINQ, etc.
![Page 22: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/22.jpg)
ADO.NET
Define list structures and primary/foreign keysRemember data type limitations
Retrieve list objects via OM or Web Services
Create relational DataSet objects, merge into single DataTable
Use stand-beside DB for caching and native SQL queries
![Page 23: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/23.jpg)
LINQ
Simplifies programming Allows for normalized query language
similar to T-SQL
Performance impact is dictated by type of operation
Lists expose XML which can be directly queried
![Page 24: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/24.jpg)
Recursive Site Queries Avoid direct database queries Create Timer Job or Windows Service to
execute recursion code Schedule for off-peak hours Store results in separate database Query against custom DB Batch bulk update tasks using Web services Avoid populating data warehouse via
event handlers
![Page 25: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/25.jpg)
Best Practices Site Objects – Use CAML to retrieve list
objectsCreate custom web parts to display large
datasets Cross-Site Objects – PortalSiteMapProvider
and Search provide optimal performance External Objects
SP to SP – Use web servicesOther – Employ least overhead-intensive
method Data Aggregation – Relational list methods
should be reserved for smaller datasets
![Page 26: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/26.jpg)
SharePoint Trivia
![Page 27: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/27.jpg)
Round 1:
Lists are limited to 1,000,000 individual
items
![Page 28: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/28.jpg)
Round 2:
You may omit the “ows_” prefix from field
names in Object Model CAML queries
![Page 29: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/29.jpg)
Round 3:
Web services are more efficient at retrieving large
datasets than CAML
![Page 30: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/30.jpg)
Round 4:Executing a Full Text SQL Query
against the search API returns a
ResultTable object
![Page 31: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/31.jpg)
Round 5:
Using SPList.GetListAsDataTa
ble() returns XML Encoded results
![Page 32: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/32.jpg)
Q & A
![Page 33: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/33.jpg)
Resources
![Page 34: Ep development best practices v.06](https://reader033.vdocument.in/reader033/viewer/2022061218/54b6d9ed4a7959703e8b4743/html5/thumbnails/34.jpg)
Resources SharePoint 2007 Performance and Scalability
White Paper http://blogs.msdn.com/sharepoint/archive/2008/06/17/belated-an
nouncement-sharepoint-server-2007-scalability-and-performance-whitepaper-now-available.aspx
Patterns and Practices Guidance http://www.codeplex.com/spg