A collection of extension methods both for general .NET

Do not enable ObjectTracking in Linq.DataContext. Do not access SPListCollection by indexer multiple times. Do not call SPFolder.Files.Count. Use SPBuiltInContentTypeId to reference builtin ContentType. Use SPBuiltInFieldId to reference builtin Field . Define RowLimit for SPQuery. Avoid using AppSettings to store configuration values. Apply lock when caching SharePoint objects. Do not call A collection of extension methods both for general .NET and SharePoint 2010/2013 specific usage - LS.Extensions.cs using System.Linq; using System.Text; using Microsoft.SharePoint; namespace Content { class Program { static void Main(string[] args) { Console.WriteLine(“Enter the name of your site and press enter”); string siteurl = Console.ReadLine(); using (SPSite site = new SPSite(siteurl)) { using (SPWeb web = site.OpenWeb()) { //Check to see if we should just create a content type //or move on to As for the rest of the code... if you're using .NET 3.5 you could just use LINQ: return sPContentTypeCollection.Cast<SPContentType>() .First(type => type.Name == contentTypeName); That will throw an InvalidOperationException for you automatically if the name isn't found. Or if you want to return null: The cause is that when it iterates over all SpContentTypeCollection for each list, the content type exists in SHarepoint, but the feature definition file does not exist in the feature folder. Really weird! The fix: I added the content type again in the 1st solution to the feature, recompiled, repackaged, updated the solution and voila. My site is working again. This was really complcated to I'm just trying to mock the SPContentTypeCollection class out of the SharePoint 2010 assembly but I'm facing a problem arranging a mock for the "BestMatch" method. I've already searched for a solution but cannot find any information about it. This is my testcode: SharePoint Content Type IDs - Reference: Here is the reference for SharePoint 2010 Parent content type id format: Content Type ID S... SPContentTypeId ctId = voucherRequestListContentType.Id; // LINQ where clause: .Where(library => (...) && library.ContentTypes[ctID] != null); The method SPList.IsContentTypeAllowed checks if a given content type is supported on the list and not if the content type is part of the list. See the MSDN documentation SPList.IsContentTypeAllowed Method. Linq + 2 Get link; Facebook; Twitter; Pinterest; Email; Other Apps; SharePoint 2010 Sandboxed Solutions December 25, 2009 Sandboxed SharePoint 2010 Solution Validator + 0 Get link ; Facebook; Twitter; Pinterest; Email; Other Apps; Installing SharePoint 2010 Beta December 21, 2009 Beta Install SharePoint 2010 + 1 Get link; Facebook; Twitter; Pinterest; Email; Other Apps; Reading App.Config Key SPContentTypeCollection.BestMatch method Message Suppression To suppress this violation in managed code add the following attribute to the method which contains the instruction (available since SPCAF version v5.2).

[index] [22312] [9984] [4751] [4718] [17800] [15416] [1386] [18284] [7400] [15896]