1
votes

I'm struggling with my first BDC model in Sharepoint 2010. I have created a very simple model with just 1 entity. I try to find a specific entry by doing:

    private IEntityInstance GetBdcEntityInstance(string nr, string entityName)
    {
        Identity id = new Identity(nr);
        IEntity entity = mCatalog.GetEntity(Constants.BdcNavEntityNameSpace, pEntityName);
        IEntityInstance instance = entity.FindSpecific(id, navLobSystemInstance);
        return instance;
    }

navLobSystemInstance is initialized with:

mNavLobSystemInstance = mCatalog.GetLobSystem("NAVViews").GetLobSystemInstances()["NAVViews"];

This method crashes at entity.FindSpecific with the following error:

This Entity (External Content Type) does not belong to the LobSystemInstance (External System Instance) provided. Parameter name: lobSystemInstance"

I think this tries to tell me that the Entity is not part of the LOB system I have defined, so I must have messed up the BDC model XML, propably. I'm new also to this particular XML jungle format, and I have tried a number of things, but I just don't understand this well enough to see any 'obvious' errors. Anyone an idea?

Here is the full BDC model XML:

<?xml version="1.0" encoding="utf-8"?>
<Model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/windows/2007/BusinessDataCatalog" Name="NAVViews">
  <Properties>
    <Property Name="ConnectionString" Type="System.String"></Property>
  </Properties>
  <LobSystems>
    <LobSystem Name="NAV" Type="DotNetAssembly">
      <LobSystemInstances>
        <LobSystemInstance Name="NAVViews" />
      </LobSystemInstances>
      <Entities>
        <Entity Name="BdcCustomer" Namespace="BdcNAVModel.NAVViews" Version="1.0.0.1">
          <Properties>
            <Property Name="Class" Type="System.String">BdcNAVModel.NAVViews.BdcCustomerService, NAVViews</Property>
          </Properties>
          <Identifiers>
            <Identifier Name="No" TypeName="System.String" />
          </Identifiers>
          <Methods>
            <Method Name="ReadItem">
              <Parameters>
                <Parameter Name="returnParameter" Direction="Return">
                  <TypeDescriptor Name="BdcCustomer" TypeName="BdcNAVModel.NAVViews.BdcCustomer, NAVViews" IsCollection="false">
                    <TypeDescriptors>
                      <TypeDescriptor Name="No" TypeName="System.String" />
                      <TypeDescriptor Name="Name" TypeName="System.String" />
                      <TypeDescriptor Name="Name2" TypeName="System.String" />
                      <TypeDescriptor Name="Address" TypeName="System.String" />
                      <TypeDescriptor Name="Address2" TypeName="System.String" />
                      <TypeDescriptor Name="ZipCode" TypeName="System.String" UpdaterField="false" />
                      <TypeDescriptor Name="City" TypeName="System.String" />
                      <TypeDescriptor Name="CountryRegion" TypeName="System.String" />
                      <TypeDescriptor Name="PhoneNo" TypeName="System.String" />
                      <TypeDescriptor Name="SalesPersonCode" TypeName="System.String" />
                      <TypeDescriptor Name="CountryRegionCode" TypeName="System.String" />
                    </TypeDescriptors>
                    </TypeDescriptor>
                    </Parameter>
                <Parameter Name="CustomerNo" Direction="In">
                  <TypeDescriptor Name="CustomerNo" TypeName="System.String" /></Parameter>
              </Parameters>
              <MethodInstances>
                <MethodInstance Name="ReadItem" Type="SpecificFinder" ReturnParameterName="returnParameter" ReturnTypeDescriptorPath="BdcCustomer" />
              </MethodInstances></Method>
            <Method Name="ReadList">
              <Parameters>
                <Parameter Name="customerList" Direction="Return">
                  <TypeDescriptor Name="CustomerList" TypeName="System.Collections.Generic.IEnumerable`1[[BdcNAVModel.BdcCustomer, NAVViews]]" IsCollection="true">
                    <TypeDescriptors>
                      <TypeDescriptor Name="BdcCustomer" TypeName="BdcNAVModel.NAVViews.BdcCustomer, NAVViews" IsCollection="false">
                        <TypeDescriptors>
                          <TypeDescriptor Name="No" TypeName="System.String" />
                          <TypeDescriptor Name="Name" TypeName="System.String" />
                          <TypeDescriptor Name="Name2" TypeName="System.String" />
                          <TypeDescriptor Name="Address" TypeName="System.String" />
                          <TypeDescriptor Name="Address2" TypeName="System.String" />
                          <TypeDescriptor Name="ZipCode" TypeName="System.String" />
                          <TypeDescriptor Name="City" TypeName="System.String" />
                          <TypeDescriptor Name="CountryRegion" TypeName="System.String" />
                          <TypeDescriptor Name="PhoneNo" TypeName="System.String" />
                          <TypeDescriptor Name="SalesPersonCode" TypeName="System.String" />
                          <TypeDescriptor Name="CountryRegionCode" TypeName="System.String" /></TypeDescriptors></TypeDescriptor></TypeDescriptors>
                    </TypeDescriptor></Parameter>
              </Parameters>
              <MethodInstances>
                <MethodInstance Name="ReadList" Type="Finder" ReturnParameterName="customerList" ReturnTypeDescriptorPath="CustomerList" />
              </MethodInstances></Method>
          </Methods></Entity>
      </Entities>
    </LobSystem>
  </LobSystems>
</Model>
1

1 Answers

0
votes

The LogSystemInstance Name that you put (NAVViews), should be the name of the TypeDescriptor that you return (BdcCustomer). Those two should correspond to the name of your entity, which I suppose is BdcCustomer. So try to change this line:

<LobSystemInstance Name="NAVViews" />

Into that:

<LobSystemInstance Name="BdcCustomer" />

You can also take a look on this xml model, that I worked with recently.