I have an SP list of items, each item has a unique Title. I would like to use the title as my way to find and then update that row of data. I thought the below code would find only the item that has a Title = "Apptest" but it always gives me all items in the list and all of them are updated. I get the same results if I remove the ViewXml line, so I think there is something wrong with that line but I can't find it. Before: After:
var list = clientContext.Web.Lists.GetByTitle("Test");
var camlQuery = new CamlQuery
{
ViewXml = @"<Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>Apptest</Value></Eq></Where></Query>"
};
var listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
foreach (var listItem in listItems)
{
Console.WriteLine($"{listItem["Title"]}");
listItem["Title"] = "AppUpdateTest";
listItem.Update();
clientContext.ExecuteQuery();
}