Ask a questionAsk a question
 

QuestionUnable to retrieve BDC entities to SharePoint site

  • Saturday, October 31, 2009 1:50 PMchaitanya sandeep Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi All,

    I have used 'Microsoft.Office.Server.ApplicationRegistry.MetadataModel.ApplicationRegistry' in my code for Loading the BDC applications to a dropdown in MOSS 2007 site. It worked fine and BDC applications and entities were loaded to the dropdowns.

    Now I have migrated the site to SharePoint 2010 and it gives the following warning :

    'Microsoft.Office.Server.ApplicationRegistry.MetadataModel.ApplicationRegistry' is obselete: 'O12 Application Registry API is deprecated. Please Use BusinessData.'


    However I am able to build the code in VS. But the BDC applications are not loaded to the dropdown.

    Can someone suggest me on what I have to do?

    Thanks in advance :)

All Replies

  • Monday, November 16, 2009 2:55 PMScot HillierMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You need a reference to Microsoft.SharePoint.dll and Microsoft.BusinessData.dll then the foloowing code

    BdcServiceApplicationProxy p =

          (BdcServiceApplicationProxy)SPServiceContext.Current.GetDefaultProxy(

          typeof(BdcServiceApplicationProxy));           

    DatabaseBackedMetadataCatalog catalog = sap.GetDatabaseBackedMetadataCatalog();

    IEntity ect = catalog.GetEntity("MyEntityNamespace", "MyEntityName");

    ILobSystem lob = ect.GetLobSystem();

    ILobSystemInstance lobi = lob.GetLobSystemInstances()["MyLOBSystemInstanceName"];

    IFilterCollection filter = ect.GetDefaultFinderFilters();

    IEntityInstanceEnumerator ects = ect.FindFiltered(filter, lobi);

    while (ects.MoveNext())

    {

        Console.WriteLine(ects.Current["MyEntityFieldName"].ToString());

    }