List Information Update

var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (var clsCon = spContext.CreateUserClientContextForSPHost())
{
var web = clsCon.Web;
var list = web.Lists.GetByTitle(“Sample List”);
// list.Description = “Sample list descriptiton upadate”;
list.EnableFolderCreation = true;
list.EnableAttachments = false;
list.OnQuickLaunch = true;
list.EnableVersioning = true;
list.Update();
clsCon.Load(list);

//list.DeleteObject();
clsCon.ExecuteQuery();
Response.Write(list.Title);
}

Advertisements
List Information Update

create a new list in the website Using CSOM

var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (var clsCon=spContext.CreateUserClientContextForSPHost())
{
ListCreationInformation createInfo = new ListCreationInformation();
createInfo.Title = “Sample List”;
createInfo.Description = “Saample list create using CSOM”;
createInfo.TemplateType = (int)ListTemplateType.GenericList;

List newList = clsCon.Web.Lists.Add(createInfo);
clsCon.Load(newList);
clsCon.ExecuteQuery();

Response.Write(newList.Title);
}

create a new list in the website Using CSOM

CAML Queries Example in CSOM

CAML Queries Example in CSOM

var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (var clc = spContext.CreateUserClientContextForSPHost())
{
var web = clc.Web;
var prodList = web.Lists.GetByTitle(“Products”);
var query = new CamlQuery();
query.ViewXml = “<View />”;
var items = prodList.GetItems(query);

clc.Load(prodList, lt => lt.Title);
clc.Load(items);
clc.ExecuteQuery();

lbox.Items.Add(prodList.Title);

foreach (var it in items)
{
lbox.Items.Add(it[“Title”].ToString());
}
}

Reff:

https://karinebosch.wordpress.com/2012/02/03/caml-and-the-client-object-model/

https://msdn.microsoft.com/en-us/library/ff798388.aspx

Tools:

https://karinebosch.wordpress.com/my-articles/caml-designer-for-sharepoint-2013/

CAML Queries Example in CSOM

Example : Load and LoadQuery

Load

var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

using (var clsContest = spContext.CreateUserClientContextForSPHost())
{
clsContest.Load(clsContest.Web, web => web.Title, web => web.Lists);
clsContest.ExecuteQuery();
lbox.Items.Add(clsContest.Web.Title);
lbox.Items.Add(clsContest.Web.Lists.Count.ToString());
}

LoadQuery()

var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (var clsContext=spContext.CreateUserClientContextForSPHost())
{
var web = clsContext.Web;

var query = from list in web.Lists
where list.Hidden == false &&
list.Fields.Count>0
select list;
var lists=clsContext.LoadQuery(query);
clsContext.ExecuteQuery();Response.Write(lists.Count());
}

Reffe: http://www.learningsharepoint.com/2010/08/11/load-vs-loadquery/

http://www.enjoysharepoint.com/Articles/Details/difference-between-loadquery-and-loaddataquery-in-sharepoint-2010-20661.aspx

http://praveenbattula.blogspot.com/2010/03/sharepoint-2010-loadquery-vs-load.html

Example : Load and LoadQuery