Condividi tramite


ListDataSource Class

Represents information associated with a connection to an external data source.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Client.ClientValueObject
    Microsoft.SharePoint.Client.ListDataSource

Namespace:  Microsoft.SharePoint.Client
Assemblies:   Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

Syntax

'Declaration
<ScriptTypeAttribute("SP.ListDataSource", ValueObject := True, ServerTypeId := "{06bfe4a5-1516-4b55-a6d7-ecbe3ff7a3c8}")> _
Public NotInheritable Class ListDataSource _
    Inherits ClientValueObject
'Usage
Dim instance As ListDataSource
[ScriptTypeAttribute("SP.ListDataSource", ValueObject = true, ServerTypeId = "{06bfe4a5-1516-4b55-a6d7-ecbe3ff7a3c8}")]
public sealed class ListDataSource : ClientValueObject

Examples

This code example shows which lists on the specified site are external.

using System;
using Microsoft.SharePoint.Client;

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

            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;
            clientContext.Load(site);
            ListCollection collList = site.Lists;
            clientContext.Load(
               collList,
               lists => lists
                  .Include(
                     list => list.Title,
                     list => list.DataSource)
               ); 
            clientContext.ExecuteQuery();

            string messageExternal = "External Lists:\n";
            string messageNormal = "Normal Lists:\n";
            foreach (List targetList in collList)
               if (targetList.DataSource != null)
               {
                  // Get connection properties of the ListDataSource object.
                  messageExternal += "\n\t" + targetList.Title
                     + "(Entity=" + targetList.DataSource.Properties["Entity"] + "; "
                     + "LOB System=" + targetList.DataSource.Properties["LobSystemInstance"];
               }
               else
               {
                  messageNormal += "\n\t" + targetList.Title;
               }
            Console.WriteLine(messageExternal);
            Console.WriteLine(messageNormal);
        }
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ListDataSource Members

Microsoft.SharePoint.Client Namespace