BizTalk适配器生成分层架构

时间:2017-12-28 12:13:01

标签: sql wcf xsd biztalk biztalk-2016

我正在尝试使用BizTalk适配器(SQL或WCF-SQL)来创建多级分层架构。我的查询是这样的

SELECT
    CustomerQueueMessage.customer_queue_ID  AS CustomerQueueMsgID,
    CustomerMaster.customer_ID              AS [CustomerID],
    CustomerAddressType.address_type_ID     AS [AddressTypeID],         
    CustomerSalesRep.sales_rep_type_code    AS [SalesRepTypeCode]
 FROM CustomerQueue AS CustomerQueueMessage 
 INNER JOIN dbo.MDM_Customer                AS CustomerMaster       ON (CustomerQueueMessage.customer_queue_ID = CustomerMaster.customer_queue_ID)
 INNER JOIN dbo.MDM_CustomerAddressType     AS CustomerAddressType  ON (CustomerAddressType.customer_queue_ID  = CustomerMaster.customer_queue_ID)
 INNER JOIN dbo.MDM_CustomerSalesRep        AS CustomerSalesRep     ON (CustomerSalesRep.customer_queue_ID     = CustomerMaster.customer_queue_ID)
 FOR XML AUTO, TYPE, ELEMENTS, XMLDATA

当我使用SQL适配器生成模式时,我得到了这个结构

this snippet

我想要的是

enter image description here

CustomerSalesRep 位于 CustomerAddressType 下。我希望 CustomerSalesRep CustomerAddressType 处于同一级别,并且都在 CustomerMaster 下。

如果我删除FOR XML语句并使用WCF-SQL适配器生成模式,我没有层次结构,所有列都处于同一级别。

有什么想法吗?我希望使用WCF-SQL适配器,但SQL也可以。

1 个答案:

答案 0 :(得分:1)

你可以使用它。

SELECT
    CustomerSalesRep.sales_rep_type_code    AS "CustomerQueueMessage/CustomerMaster/CustomerSalesRep/SalesRepTypeCode",
    CustomerAddressType.address_type_ID     AS "CustomerQueueMessage/CustomerMaster/CustomerAddressType/AddressTypeID",         
    CustomerMaster.customer_ID              AS "CustomerQueueMessage/CustomerMaster/CustomerID",
    CustomerQueueMessage.customer_queue_ID  AS "CustomerQueueMessage/CustomerQueueMsgID"
 FROM CustomerQueue AS CustomerQueueMessage 
 INNER JOIN dbo.MDM_Customer                AS CustomerMaster       ON (CustomerQueueMessage.customer_queue_ID = CustomerMaster.customer_queue_ID)
 INNER JOIN dbo.MDM_CustomerAddressType     AS CustomerAddressType  ON (CustomerAddressType.customer_queue_ID  = CustomerMaster.customer_queue_ID)
 INNER JOIN dbo.MDM_CustomerSalesRep        AS CustomerSalesRep     ON (CustomerSalesRep.customer_queue_ID     = CustomerMaster.customer_queue_ID)
 FOR XML PATH('SAPcustom'), TYPE, ELEMENTS

它会生成这样的XML。

<SAPcustom>
  <CustomerQueueMessage>
    <CustomerMaster>
      <CustomerSalesRep>
        <SalesRepTypeCode>1</SalesRepTypeCode>
      </CustomerSalesRep>
      <CustomerAddressType>
        <AddressTypeID>1</AddressTypeID>
      </CustomerAddressType>
      <CustomerID>1</CustomerID>
    </CustomerMaster>
    <CustomerQueueMsgID>1</CustomerQueueMsgID>
  </CustomerQueueMessage>
</SAPcustom>