SHAREPOINT AND PROJECT CONFERENCE ADRIATICS 2013ZAGREB, NOVEMBER 27-28 2013
Hard learned SharePoint dev tips
SAHIL MALIK
WWW.WINSMARTS.COM
@SAHILMALIK
sponsors
C:\>whoami
11xMVP
15xAuthor
Pluralsight Author
Microsoft Metro Trainer
Funny and Honest
HTTP://BLAH.WINSMARTS.COM@SAHILMALIK
Hard learned SharePoint dev tips Hard learned CSOM and REST
0945AM 0345PM
Lists and Document Libraries
Lists live in SPWebs
dbo.AllLists
Primary Key for AllLists
Content Types – will make performance worse
tp_Fields
dbo.AllUserData
My Test List
Example
Example 2
tp_ColumnSet
Sparse Columns
AllUserDatatp_ID identify the list item
tp_GUID To uniquely identify the list item
tp_ListId To identify which list the item belongs to.
tp_SiteId To identify which site the item belongs to. It is the value of ‘Id’ in ‘AllSites’ table
tp_RowOrdinal Zero based ordinal index in the set of rows representing the list item
tp_Author User who created the list item
tp_Editor User who last edited the list item
tp_Modified Modified date
tp_Created Created date
tp_DeleteTransactionID Not 0x if the item is in recycle bin
tp_IsCurrentVersion (bit) 1 or 0, identifying latest version
nvarchar1..64 Stores values of application fields of type nvarchar
ntext1..32 Stores application fields of type ntext
bit1..16 Application fields of type bit
datetime1..8 Application fields of type datetime
AllUserData
float 1..12 Application fields of type float
Int1..16 Application fields of type int
sql_variant1..8 Application fields of type sql_variant
AllUserData - takeaways
Now lets talk documents!
Test Data
How are documents stored?
Document Storage
DocStreams
Scientifically accurate picture of RBS
Document Storage – Lessons Learnt
Careful of iterators!
Avoids multiple calls to DB
Does not create SPListItemCollection over and over again
Number of Items in a list
SPQuery is your friend2147483648
And its getting every single column!
Avoid reloading objects
SharePoint objects are not threadsafe!
Getting a list
proc_EnumLists
proc_MapUrlToListAndView
proc_EnumLists loads all information of all lists in the SPWeb object, and then does a .Title comparison to find the
list you need.
proc_MapUrlToListAndView finds the GUID for the associated list, and then loads the metadata for the list you
need.
Deleting Items
Good vs Evil
Evil Good
SPList.Items.Count SPList.ItemsCount
SPList.Items[Guid] SPList.GetItemByUniqueId(Guid)
SPList.Items[Int32] SPList.GetItemById(Int32)
SPList.Items.GetItemById(Int32) SPList.GetItemById(Int32
SPList.Items.NumberOfFields SPQuery + ViewFields
SPList.Items.ReorderItems Use SPQuery.ListItemCollectionPosition to do paging
SPFolder.Files.Count SPFolder.ItemCount
.Dispose
.Dispose
questions?
HTTP://BLAH.WINSMARTS.COM
@SAHILMALIK
thank you.
SHAREPOINT AND PROJECT CONFERENCE ADRIATICS 2013ZAGREB, NOVEMBER 27-28 2013