Create
using (ClientContext context = new ClientContext(url)) { //set credentials ICredentials cache = new NetworkCredential(userName, password); context.Credentials = cache; List barcodeReaderList = context.Web.Lists.GetByTitle(listName); ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); ListItem item = barcodeReaderList.AddItem(itemCreateInfo); item["Title"] = barcode; item.Update(); context.ExecuteQuery(); }
Update
using (ClientContext context = new ClientContext(url)) { //set credentials ICredentials cache = new NetworkCredential(userName, password, domain); context.Credentials = cache; List list = context.web.Lists.GetByTitle(listName); ListItem item = list.GetItemById(id); item["Title"] = title; item.Update(); context.ExecuteQuery(); }Delete
using (ClientContext context = new ClientContext(url)) { List list = context.Web.Lists.GetByTitle(listName); ListItem item = list.GetItemById(id); item.DeleteObject(); context.ExecuteQuery(); }
Read
private IEnumerablenewLists; var dt = new DateTime(2010, 3, 20); var query = from list in clientContext.Web.Lists where list.Created > dt && list.Hidden == false select list; newLists = clientContext.LoadQuery(query); clientContext.ExecuteQueryAsync(onPartQuerySucceeded, onPartQueryFailed);
No comments:
Post a Comment