我在Sharepoint 2010中遇到了我的第一个BDC模型。我创建了一个只有1个实体的非常简单的模型。我尝试通过以下方式找到特定条目:
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>
答案 0 :(得分:0)
您放置的LogSystemInstance名称(NAVViews)应该是您返回的TypeDescriptor的名称(BdcCustomer)。这两个应该对应于您的实体的名称,我想这是BdcCustomer。所以试着改变这一行:
<LobSystemInstance Name="NAVViews" />
进入那个:
<LobSystemInstance Name="BdcCustomer" />
您还可以查看我最近合作的this xml model。