次の方法で共有


Using the SharePoint 2010 Managed Client Object Model – Using the LoadQuery Method

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

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

Blog TOC

using System;
using System.Collections.Generic;
using Microsoft.SharePoint.Client;

class Program
{
static void Main(string[] args)
{
ClientContext clientContext =
new ClientContext("https://intranet.contoso.com");
Web site = clientContext.Web;
ListCollection lists = site.Lists;
IEnumerable<List> newListCollection = clientContext.LoadQuery(
lists.Include(
list => list.Title,
list => list.Id,
list => list.Hidden));
clientContext.ExecuteQuery();
foreach (List list in newListCollection)
Console.WriteLine("Title: {0} Id: {1}",
list.Title.PadRight(40), list.Id.ToString("D"));
}
}

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

using System;
using System.Collections.Generic;
using Microsoft.SharePoint.Client;

class Program
{
static void Main(string[] args)
{
Microsoft.SharePoint.Client.ClientContext clientContext =
new Microsoft.SharePoint.Client.ClientContext("https://intranet.contoso.com");
Microsoft.SharePoint.Client.Web site = clientContext.Web;
Microsoft.SharePoint.Client.ListCollection lists = site.Lists;
IEnumerable<Microsoft.SharePoint.Client.List> newListCollection = clientContext.LoadQuery(
lists.Include(
list => list.Title,
list => list.Id,
list => list.Hidden));
clientContext.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.List list in newListCollection)
Console.WriteLine("Title: {0} Id: {1}",
list.Title.PadRight(40), list.Id.ToString("D"));
}
}