January 17, 2021
Hot Topics:

Business Data Catalog in Microsoft Office SharePoint Server 2007 and the Object Model

  • By Gustavo Velez
  • Send Email »
  • More Articles »

The next routine loops through the complete schema, showing the relevant information:

static void GetProperties()
   NamedLobSystemInstanceDictionary mySysInstances =

   foreach (string mySysInstanceName in mySysInstances.Keys)
      LobSystemInstance myLobSystemInstance =
      LobSystem myLobSystem = myLobSystemInstance.GetLobSystem();
      Console.WriteLine("SystemLOB  - " + myLobSystem.Name);
      Console.WriteLine("* Instance - " + mySysInstanceName);

      NamedEntityDictionary myEntities =
      foreach (string myEntity in myEntities.Keys)
         Entity oneEntity =
         Console.WriteLine("** Entity - " + oneEntity.Name);

         NamedMethodDictionary myMethods = oneEntity.GetMethods();
         foreach (string myMethod in myMethods.Keys)
            Method oneMethod = oneEntity.GetMethods()[myMethod];
            Console.WriteLine("*** Method - " + oneMethod.Name);

            NamedPropertyDictionary myProperties =
            Console.WriteLine("\n\r" + "**** Query - " +

The first element of a BDC schema identifies the schema with a specific name. The "NamedLobSystemInstanceDictionary" contains the collection of schemas in the Catalog, and the "GetLobSystemInstances" method fills the variable with the schemas present in the system.

By looping through the collection, it is possible to find all the relevant information about the LOB's Instances and systems, and the routine prints the name of the LOB system and the name of the Instance.

Each LOB System Instance contains one or more Entities. The "NamedEntityDictionary" contains the collection and the "GetEntities" method loads the variable with the Entities in the Instance. Continue using a 'foreach' statement to examine each Entity and make an instance of them to display and use its properties (the name of the entity will be printed in the example).

In a similar way, each Entity embraces one or more Methods. These are contained in the "NamedMethodDictionary" collection and can be filled using the method "GetMethods" of the entity. Looping through the different methods, an instance of the method is made and one of the properties printed (its name). Apart from properties reached from the Object Model, the Method object has a "NamedPropertyDictionary" bag with its properties; in the example, an instance of the collection is made, filled with the "GetProperties" method, and one of the properties is printed on the screen; namely, the query used in the schema to retrieve the data from the database.

Click here for a larger image.

Figure 2: Routine results for reading the BDC schema

Reading the Output

It also is possible to execute a Business Data Catalog and read the output using the MetadataModel and Runtime NameSpaces. The next routine shows the results from the example's BDC:

static void GetData()
   NamedLobSystemDictionary myLobSysDictionary =

   foreach (LobSystem system in myLobSysDictionary.Values)
      NamedLobSystemInstanceDictionary mySysInstances =

      foreach (LobSystemInstance oneInstance in mySysInstances.Values)
         Entity myEntity =
         FilterCollection myFilterCollection =
         IEntityInstanceEnumerator myEntityInstanceEnumerator =
            myEntity.FindFiltered(myFilterCollection, oneInstance);

         while (myEntityInstanceEnumerator.MoveNext())
            DataTable myZooDataTable =
               (myEntityInstanceEnumerator.Current as
            foreach (DataColumn oneAnimal in
               Console.Write(myZooDataTable.Rows[0][oneAnimal] + "\t");

Page 2 of 4

This article was originally published on October 17, 2007

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date