Introduction:
In this article we will learn how to delete a list in SharePoint 2013 using .NET Framework client object model (CSOM). We can use the SharePoint client object model to create data in SharePoint 2013.
SharePoint makes the object model available in several forms.
- .NET Framework redistributable assemblies-CSOM & SSOM
- JavaScript library
- REST/OData endpoints
The following article describe tasks that you can complete programmatically, and they include C# code examples that demonstrate CSOM operations.
When you create a Console Application in Visual Studio Select below assembly reference file,
Prerequisites:
- Visual Studio 2012
- SQL Server
- SharePoint Server and Dll
- Admin access to the Sharepoint Site.
Microsoft.SharePoint.Client.Runtime.dll
Microsoft.SharePoint.Client.dll.
Addbelowusing statement to the code file.
usingMicrosoft.SharePoint.Client;
Explanation:
Run Visual Studio and select the Console application and name it Create a List,
And select the assembly reference file in Visual studio,
Then type the below using Statement,
usingMicrosoft.SharePoint.Client;
Source Code:
Then Copy the below csomcode and paste it in Visual Studio,
- using System;
- usingSystem.Collections.Generic;
- usingSystem.Linq;
- usingSystem.Text;
- usingSystem.Threading.Tasks;
- usingMicrosoft.SharePoint;
- usingMicrosoft.SharePoint.Client;
-
-
- namespaceDelete_ListItem
- {
- classProgram
- {
- staticvoid Main(string[] args)
- {
- ClientContextctx = newClientContext("http://gowtham.sharepoint.com");
-
- Web web = context.Web;
-
- List list = web.Lists.GetByTitle("TestList");
- list.DeleteObject();
-
- context.ExecuteQuery();
- }
- }
- }
OutPut:
Check the SharePoint Site Listitem has been deleted successfully.