Thursday 1 September 2011

How to get a SharePoint list using SharePoint object model

In this post i want to discuss how you can get a SharePoint list using SharePoint object model. To do this make  sure you have SharePoint installed on your PC. Now create a new console project in Visual Studio 2010. Make sure that the platform target for your project is 64 bit and that you added the SharePoint dll as a reference.

Now, i have already added a custom list to my site and it is called My List. It has two columns, Name and Surname. So this is just a small list of random Names and Surnames.

 
 If you are done with your list, lets get the same list and display it from the Console application.

 If you run the code you will get the list you just created from SharePoint.


So this how you can simply get a SharePoint list using SharePoint object model.