Basic operations on Lists with the SharePoint 2013

This article explains the code to perform basic operations on Lists with the SharePoint 2013 .NET Framework client object model (CSOM). The SharePoint 2013 object model for .NET Framework is used in .NET Framework applications that run on a non-phone Windows client. Any of the following counts as such a client user's computer, server that is external to the SharePoint 2013 farm, web role or worker role on Microsoft Azure.

Almost every class in the core site and list server object model has a corresponding class in the .NET Framework client object model. In addition, the .NET Framework client object model exposes a full set of APIs for extending other features, including some SharePoint Server 2013 features such as ECM, taxonomy, user profiles, advanced search, analytics, BCS, and others.

1. Create and Update sharePoint list

  1. ClientContext context = new ClientContext("http://SiteUrl");   
  2.   
  3. Web web = context.Web;   
  4.   
  5. ListCreationInformation creationInfo = new ListCreationInformation();   
  6. creationInfo.Title = "List_Name";   
  7. creationInfo.TemplateType = (int)ListTemplateType.Announcements;   
  8. List list = web.Lists.Add(creationInfo);   
  9. list.Description = "Description_of_List";   
     
  10. list.Update();  
    context.ExecuteQuery();  

2. Delete SharePoint List

  1. ClientContext context = new ClientContext("http://SiteUrl");  
  2. Web web = context.Web;  
  3. List list = web.Lists.GetByTitle("List_Name");  
  4. list.DeleteObject();  
  5. context.ExecuteQuery();  

Summary

In this article we have seen an overview of basic operations on Lists with the SharePoint 2013 .NET Framework client object model (CSOM).

Ebook Download
View all
Learn
View all