Shantha Kumar T
SP2010 – Tips & tricks 1
Hello guys, few weeks I had a busy schedule, so I can’t concentrate on blogging. Now I’m back with more ideas to be shared with you all.
Here I’m going to give you a simple snippet of "Retrieving the content type enabled lists" from the site using Client Object Model.
ClientContext context = new ClientContext("http://localhost");
Web web = context.Web;//Load all the lists from web
ListCollection listCollection = web.Lists;
//Filters the lists has the content type enabled
context.Load(listCollection,
lists => lists
.Include(list => list.Title)
.Where(list => list.ContentTypesEnabled)
);
//Execute the Query
context.ExecuteQuery();
Console.WriteLine("Lists enabled with ContentType:");
//Print the Content type enabled lists
foreach (var list in listCollection)
{
Console.WriteLine(list.Title);
}
The above code only returns the List collection from particular web, those are content type enabled. Next time, I’ll back with another interesting SP2010 snippet.