次の方法で共有


Using the SharePoint 2010 Managed Client Object Model – Object Identity

This is a clipboard friendly version of example #2, Object Identity, from Using the SharePoint 2010 Managed Client Object Model.

This blog is inactive.
New blog: EricWhite.com/blog

Blog TOC

using System;
using Microsoft.SharePoint.Client;

class Program
{
static void Main()
{
ClientContext clientContext =
new ClientContext("https://intranet.contoso.com");
List list = clientContext.Web.Lists.GetByTitle("Announcements");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "";
ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(list);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
foreach (ListItem listItem in listItems)
Console.WriteLine("Id: {0} Title: {1}", listItem.Id,
listItem["Title"]);
}
}

Following is the same example using fully qualified names for better discoverability.

using System;

class Program
{
static void Main()
{
Microsoft.SharePoint.Client.ClientContext clientContext =
new Microsoft.SharePoint.Client.ClientContext("https://intranet.contoso.com");
Microsoft.SharePoint.Client.List list = clientContext.Web.Lists.GetByTitle("Announcements");
Microsoft.SharePoint.Client.CamlQuery camlQuery = new Microsoft.SharePoint.Client.CamlQuery();
camlQuery.ViewXml = "";
Microsoft.SharePoint.Client.ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(list);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.ListItem listItem in listItems)
Console.WriteLine("Id: {0} Title: {1}", listItem.Id,
listItem["Title"]);
}
}