June, 2011
9 06 2011
As part of my series on performance, I thought I’d look at updating large (20,000 item) lists in bulk, and what are the fastest ways to do this. I’ve gone through a few different ways of doing this, finding out where the slowness is coming from, and I present the results of the analysis in […]
1 06 2011
After this question was asked on SharePoint Stack Exchange, I thought I’d share my method of re-ordering content types in a list. Note: this isn’t the only method of doing this, see the thread on SPSE to see more (particularly the UniqueContentTypeOrder property).
|
private void ReorderContentTypes(SPWeb web, string listName, string firstContentTypeName)<br>{<br> SPList list = web.Lists[listName];<br><br> SPContentType cType = web.AvailableContentTypes[firstContentTypeName];<br><br> List<SPContentType> oldCTypes = new List<SPContentType>();<br><br> for (int i = list.ContentTypes.Count -1; i >= 0; i--)<br> {<br> if (!list.ContentTypes[i].Id.IsChildOf(cType.Id))<br> {<br> oldCTypes.Add(list.ContentTypes[i]);<br><br> list.ContentTypes[i].Delete();<br> }<br> }<br><br> foreach (SPContentType c in oldCTypes)<br> {<br> list.ContentTypes.Add(c);<br> }<br><br> list.Update();<br>}<br> |