Steps
- Open Visual Studio in your system
- Select Console Applciation template and give as name "RetrieveListItems"
- Add a Microsoft.Cleint Assembly refrence file in right side refrence tab in visual studio.
- Replace Program.cs with the source code below.
- using System;
- using Microsoft.SharePoint.Client;
- using SP = Microsoft.SharePoint.Client;
- namespace Microsoft.SDK.SharePointServices.Samples
- {
- class RetrieveListItems
- {
- static void Main()
- {
- string siteUrl = "http://gauti.sharepoint.com/sites/SP";
- ClientContext clientContext = new ClientContext(siteUrl);
- SP.List oList = clientContext.Web.Lists.GetByTitle("NewBook");
- CamlQuery camlQuery = new CamlQuery();
- camlQuery.ViewXml = "<View><Query><Where><Geq><FieldRef Name='ID'/>" +
- "<Value Type='Number'>19</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>";
- ListItemCollection collListItem = oList.GetItems(camlQuery);
- clientContext.Load(collListItem);
- clientContext.ExecuteQuery();
- foreach (ListItem oListItem in collListItem)
- {
- Console.WriteLine("ID: {0} \nTitle: {1} \nBody: {2}", oListItem.Id, oListItem["Title"], oListItem["Body"]);
- }
- }
- }
- }
Hit F5 and see the magix happend in SharePoint 2013. Hope you have enjoyed this.!!! :-)

Muthu PrasanthPosted May 14, 2018, 4:01 AM
Hi Gowtham, I have a doubt. Below is my code var list = clientContext.Web.Lists.GetByTitle("Test_1"); clientContext.Load(list); clientContext.ExecuteQuery(); CamlQuery camlQuery = new CamlQuery(); ListItemCollection listItemcollections = list.GetItems(camlQuery); clientContext.Load(listItemcollections); clientContext.ExecuteQuery(); Console.WriteLine("File name Items count: ", listItemcollections.Count); //returns nothing foreach (ListItem oListItem in listItemcollections) { // var a="ID: {0} \tTitle: {1} \tName: {2} \n"+ oListItem.Id+ oListItem["Title"]; Console.WriteLine("oListItem values : ", oListItem["Total"]); //returns nothing Console.WriteLine("Id:" ,oListItem.Id); //returns nothing } The loop executes the number of items in the list.But it all returns as empty.Please help me to solve it
Akash KumharPosted Nov 20, 2017, 9:03 AM
Nice one.. works perfectly
kalu singh raoPosted Jul 4, 2016, 10:07 AM
Nice...
Vijay SPosted Jun 17, 2015, 9:17 AM
Good one
Santhakumar MunuswamyPosted Apr 11, 2015, 11:45 AM
Good