Export (0) Print
Expand All

ListDataSource class

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

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.Phone (in Microsoft.SharePoint.Client.Phone.dll)  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

public sealed class ListDataSource : ClientValueObject

This class serves as the bridge between List and an external list. Use the associated List to retrieve entity fields and data.

Retrieve an instance of ListDataSource from the HasExternalDataSource property. When HasExternalDataSource is not null, the List object's data is external to Microsoft SharePoint Foundation.

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);
        }
    }
}


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