IEntityInstanceEnumerator Interface

NOTE: This API is now obsolete.

Wraps a native object returned by the back-end that represents a collection or a stream as entity instances and supports a single iteration over the entity instance collection.

Namespace:  Microsoft.Office.Server.ApplicationRegistry.Runtime
Assembly:  Microsoft.SharePoint.Portal (in Microsoft.SharePoint.Portal.dll)

Syntax

'Declaration
<ObsoleteAttribute("O12 Application Registry API is deprecated. Please use BusinessData.",  _
    False)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel := True)> _
Public Interface IEntityInstanceEnumerator _
    Inherits IEnumerator(Of IEntityInstance), IDisposable, IEnumerator
'Usage
Dim instance As IEntityInstanceEnumerator
[ObsoleteAttribute("O12 Application Registry API is deprecated. Please use BusinessData.", 
    false)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.Demand, ObjectModel = true)]
public interface IEntityInstanceEnumerator : IEnumerator<IEntityInstance>, 
    IDisposable, IEnumerator

Remarks

You can use enumerators to read the data in the collection, but not to modify the underlying collection.

Because the IEntityInstanceEnumerator object supports streaming (if and only if the actual backend returns a streamable object), it is very useful when the back-end application returns large amounts of data.

Important

The IEntityInstanceEnumerator interface implements the IDisposable interface and therefore, it must be closed using the Close method or you will leak connections.

Conceptually, you can think of an entity instance as a single row of data returned from a back-end business application in the Business Data Catalog. The IEntityInstance interface abstracts the underlying data sources, insulates the clients from having to learn application-specific coding paradigms, and allows clients to access all business data in a single, simplified way. The IEntityInstance interface enables you to work with a row of data from a database in just the same way as working with a complex Microsoft .NET Framework structure returned by a Web service.

An entity instance in the Business Data Catalog has special semantics attached to it. For example, it has the ability to know which fields in the row represent the identifier for the entity instance, and to enable to you call methods such as GetAssociated(), GetIdentifierValues(), and Execute() on that entity instance.

Examples

This example shows how to execute a Finder method on the Product entity in the AdventureWorks2000 sample.

Prerequisites

  • Ensure a Shared Service Provider is already created.

  • Replace the constant value EnterYourSSPNameHere in the code with the name of your Shared Resource Provider.

  • Ensure the LobSystem object and entity names referenced in the example exist in the Business Data Catalog. Use valid names.

Project References

Add the following Project References in your console application code project before running this sample:

  • Microsoft.SharePoint

  • Microsoft.SharePoint.Portal

  • Microsoft.Office.Server

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Microsoft.Office.Server.ApplicationRegistry.MetadataModel;
using Microsoft.Office.Server.ApplicationRegistry.Runtime;
using Microsoft.Office.Server.ApplicationRegistry.SystemSpecific;
using Microsoft.Office.Server.ApplicationRegistry.Infrastructure;
using WSSAdmin = Microsoft.SharePoint.Administration;
using OSSAdmin = Microsoft.Office.Server.Administration;

namespace Microsoft.SDK.SharePointServer.Samples
{
    class ExecuteFinder
    {
        const string yourSSPName ="EnterYourSSPNameHere";

        static void Main(string[] args)
        {
            SetupBDC();
            FindAll();
            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }
        static void SetupBDC()
        {
            SqlSessionProvider.Instance().SetSharedResourceProviderToUse(yourSSPName);
        }

        static void FindAll()
        {
            NamedLobSystemInstanceDictionary sysInstances = ApplicationRegistry.GetLobSystemInstances();
            LobSystemInstance AdvWorksIns = sysInstances["AdventureWorksSampleInstance"];
            Entity prodEntity = AdvWorksIns.GetEntities()["Product"];
            FilterCollection fc = prodEntity.GetFinderFilters();
            // leave the filtercollection unmodified - don't set any filters, and then Business Data Catalog will bring back everything
            IEntityInstanceEnumerator prodEntityInstanceEnumerator = prodEntity.FindFiltered(fc, AdvWorksIns);
            while (prodEntityInstanceEnumerator.MoveNext())
            {
                IEntityInstance IE = prodEntityInstanceEnumerator.Current;
                foreach (Field f in prodEntity.GetFinderView().Fields)
                    Console.Write(IE[f]);
                Console.WriteLine("");
            }
        }
       
    }
}

See Also

Reference

IEntityInstanceEnumerator Members

Microsoft.Office.Server.ApplicationRegistry.Runtime Namespace