使用客户端 OM 在不检索整个列表的情况下将新项目添加到 SharePoint 2010 列表

Adding a new item to SharePoint 2010 list using client OM without retrieving the whole list

MSDN 有这个用于将新项目添加到共享点列表的示例: </p> <pre><code>using System; using Microsoft.SharePoint.Client; using SP = Microsoft.SharePoint.Client; namespace Microsoft.SDK.SharePointServices.Samples { class CreateListItem { static void Main() { string siteUrl = "http://MyServer/sites/MySiteCollection"; ClientContext clientContext = new ClientContext(siteUrl); SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements"); ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); ListItem oListItem = oList.AddItem(itemCreateInfo); oListItem["Title"] = "My New Item!"; oListItem["Body"] = "Hello World!"; oListItem.Update(); clientContext.ExecuteQuery(); } } }

我的问题是,这段代码是否首先检索列表中存在的所有项目,然后添加新项目?
或者,它是否检索到一个空列表,以便我可以高效地向其中添加项目?

谢谢,
阿希隆

您始终可以使用 Fiddler

等网络工具检查请求

在提供的示例中,既没有检索到列表项也没有检索到列表对象,请参阅下面的评论:

var list = ctx.Web.Lists.GetByTitle(listTitle); //get List object reference (note, it is not initialized until requested from the server) 

var itemCreateInfo = new ListItemCreationInformation();
var listItem = list.AddItem(itemCreateInfo);   
listItem[propertyName] = propertyValue;
listItem.Update();     //prepare to create new List Item
ctx.ExecuteQuery();   //submit request to the server goes here