我在 Sharepoint 2010 中为我的第一个 BDC 模型而苦苦挣扎。我创建了一个非常简单的模型,只有一个实体。我尝试通过执行以下操作找到特定条目:
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 初始化为:
mNavLobSystemInstance = mCatalog.GetLobSystem("NAVViews").GetLobSystemInstances()["NAVViews"];
此方法在 entity.FindSpecific 处崩溃,并出现以下错误:
此实体(外部内容类型)不属于提供的 LobSystemInstance(外部系统实例)。参数名称:lobSystemInstance"
我认为这试图告诉我实体不是我定义的 LOB 系统的一部分,所以我一定是搞砸了 BDC 模型 XML。我对这种特殊的 XML 丛林格式也很陌生,并且我尝试了很多方法,但我只是不太了解这一点,无法看到任何“明显”的错误。任何人的想法?
这是完整的 BDC 模型 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>