[MOSS2010]利用BCS进行数据集成(三)
上回说到在给BDC添加Updater方法的时候又遇到了不顺。这回就简要的说说如何做出一个Updater来。
首先是解决上次图中的那个“Unable to find the default edit form for list ...”的问题
既然他说找不到咱就创建一个
之后笔者又遭遇了各种各样的困难,主要集中在Identifier的ReadOnly方面。先贴出最终成功的bdcm文件
<?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="BdcModel"> <LobSystems> <LobSystem Name="BdcModel" Type="DotNetAssembly"> <LobSystemInstances> <LobSystemInstance Name="BdcModel" /> </LobSystemInstances> <Entities> <Entity Name="Product" Namespace="BdcModel" EstimatedInstanceCount="1000" Version="1.0.1.0"> <Properties> <Property Name="Class" Type="System.String">BdcModel.ProductService, BdcModel</Property> </Properties> <Identifiers> <Identifier Name="ProductID" TypeName="System.Int32"/> </Identifiers> <Methods> <!-- start finder method --> <Method Name="ReadList"> <Parameters> <Parameter Direction="Return" Name="returnParameter"> <TypeDescriptor TypeName="System.Collections.Generic.IEnumerable`1[[BdcModel.Product, BdcModel]]" IsCollection="true" Name="ProductList"> <TypeDescriptors> <TypeDescriptor TypeName="BdcModel.Product, BdcModel" Name="Product"> <TypeDescriptors> <TypeDescriptor Name="ProductID" IdentifierName="ProductID" TypeName="System.Int32"/> <TypeDescriptor TypeName="System.String" Name="ProductName" /> </TypeDescriptors> </TypeDescriptor> </TypeDescriptors> </TypeDescriptor> </Parameter> </Parameters> <MethodInstances> <MethodInstance Type="Finder" ReturnParameterName="returnParameter" Default="true" Name="ReadList" DefaultDisplayName="Product List" /> </MethodInstances> </Method> <!-- end finder method --> <!-- start specific finder method --> <Method Name="ReadItem"> <Parameters> <Parameter Direction="In" Name="id"> <TypeDescriptor TypeName="System.Int32" IdentifierName="ProductID" Name="ProductID" /> </Parameter> <Parameter Direction="Return" Name="returnParameter"> <TypeDescriptor TypeName="BdcModel.Product, BdcModel" Name="Product"> <TypeDescriptors> <TypeDescriptor Name="ProductID" IdentifierName="ProductID" TypeName="System.Int32" ReadOnly="true"/> <TypeDescriptor TypeName="System.String" Name="ProductName" /> </TypeDescriptors> </TypeDescriptor> </Parameter> </Parameters> <MethodInstances> <MethodInstance Type="SpecificFinder" ReturnParameterName="returnParameter" Default="true" Name="ReadItem" DefaultDisplayName="Read Product" /> </MethodInstances> </Method> <Method Name="Update"> <Parameters> <Parameter Name="product" Direction="InOut"> <TypeDescriptor Name="Product" TypeName="BdcModel.Product, BdcModel"> <TypeDescriptors> <TypeDescriptor Name="ProductID" IdentifierName="ProductID" TypeName="System.Int32" PreUpdaterField="true" ReadOnly="true"/> <TypeDescriptor Name="ProductName" TypeName="System.String" UpdaterField="true" /></TypeDescriptors></TypeDescriptor></Parameter> </Parameters> <MethodInstances> <MethodInstance Name="Update" Type="Updater" Default="true"/> </MethodInstances></Method> <!-- end specific finder method --> </Methods> </Entity> </Entities> </LobSystem> </LobSystems> </Model>
需要注意的几点:
1 Updater Method中Parameter的Direction不可为In(本例中位InOut)
2 Updater Method中Parameter的Identifier列需要标记为PreUpdaterField
3 Updater Method中Parameter的Identifier列需要标记为ReadOnly
4 SpecificFinder Method中的Parameter的Identifier列也需要标记为ReadOnly(不知为何)
以上,Updater就算实现完了。再有creator等就需要和其他表的级联操作了。留待以后研究。