Поделиться через


Метод List.GetItems

Returns a collection of items from the list based on the specified query.

Пространство имен:  Microsoft.SharePoint.Client
Сборки:   Microsoft.SharePoint.Client.Silverlight (в Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client.Phone (в Microsoft.SharePoint.Client.Phone.dll)  Microsoft.SharePoint.Client (в Microsoft.SharePoint.Client.dll)

Синтаксис

'Декларация
Public Function GetItems ( _
    query As CamlQuery _
) As ListItemCollection
'Применение
Dim instance As List
Dim query As CamlQuery
Dim returnValue As ListItemCollection

returnValue = instance.GetItems(query)
public ListItemCollection GetItems(
    CamlQuery query
)

Параметры

Возвращаемое значение

Тип: Microsoft.SharePoint.Client.ListItemCollection
A ListItemCollection object that represents the items.

Исключения

Исключение Условие
SPException

The field specified in the query is not present in the list. Error code: -2130575340.

SPQueryThrottledException

The throttling limit is exceeded by the operation. Error code: -2147024860.Or there is a lack of resources available to process the request. Error code: -2147024749.

UnauthorizedAccessException

The user has insufficient permissions to perform the operation. Error code: -2147024891.

Замечания

It must not be пустая ссылка (Nothing в Visual Basic).

Примеры

This code example gets announcements in the current site that contain the specified string.

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointFoundation.Samples
{
    class List_getItemsExample
    {
        static void Main()
        {
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;
            List targetList = site.Lists.GetByTitle("Announcements");

            CamlQuery query = new CamlQuery();
            query.ViewXml = "<View><Query><Where><Contains><FieldRef Name='Title'/><Value Type='Text'>announce</Value></Contains></Where></Query></View>";
            ListItemCollection collListItem = targetList.GetItems(query);

            clientContext.Load(collListItem);
            clientContext.ExecuteQuery();

            if (collListItem.Count == 0)
            {
               Console.WriteLine("No items containing 'announce' found.");
            }
            else
            {
               Console.WriteLine("Items containing 'announce' found:\n");
               foreach (ListItem targetListItem in collListItem)
                  Console.WriteLine(targetListItem["Title"]);
            }
        }
    }
}

См. также

Справочные материалы

List класс

Элементы List

Пространство имен Microsoft.SharePoint.Client