Link 不是 "Primary" 实体的实体

Link an entity that isn't the "Primary" entity

我被要求使用 FetchXML 为来自 CRM 的一些数据创建一个报告。我以前从未使用过这种语言,所以我认为这可能是一个简单的问题。

我有以下代码:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="bie_backbonus" enableprefiltering="1">
    <attribute name="bie_backbonuscontractno" />
    <attribute name="bie_backbonusnoteforletter" />
    <attribute name="bie_offdate" />
    <attribute name="bie_ondate" />
    <attribute name="bie_backbonuscontractversion" />
    <attribute name="bie_backbonuscontractname" />
    <attribute name="bie_backbonuscontactname" />
    <attribute name="bie_legacybackbonuscode" />
    <attribute name="owneridname" />
    <attribute name="createdon" />
<link-entity name="bie_backbonusproductgroup" from="bie_backbonuscontractno" to="bie_backbonusid" alias="pg" link-type="outer">
    <attribute name="bie_tier2percent" />
    <attribute name="bie_tier2value" />
    <attribute name="bie_tier3percent" />
    <attribute name="bie_productsubtype" />
    <attribute name="bie_tier1value" />
    <attribute name="bie_tier3value" />
    <attribute name="bie_producttype" />
    <attribute name="bie_tier1percent" />
 </link-entity>
<link-entity name="bie_producttype" from="bie_name" to="bie_producttype" alias="p" link-type="outer">
    <attribute name="bie_producttypenl" />
</link-entity>
  </entity>
</fetch>

我已经尝试 link 上面的三个实体,但是 bie_producttype 实体需要 link 到 bie_backbonusproductgroup 实体而不是 bie_backbonus 我认为是。 link 除了 "Primary" 以外,是否有其他实体的功能或方法?

我也尝试过使用 http://www.sql2fetchxml.com/,但这产生了我的报告无法读取的代码。

我是一名 SQL 开发人员,如果用 SQL 编写,代码将是这样的:

SELECT  b.bie_backbonuscontractno
   ,b.bie_backbonusnoteforletter 
   ,b.bie_offdate
   ,b.bie_ondate
   ,b.bie_backbonuscontractversion
   ,b.bie_backbonuscontractname
   ,b.bie_backbonuscontactname
   ,b.bie_legacybackbonuscode
   ,b.owneridname
   ,b.createdon
   ,pg.bie_tier2percent
   ,pg.bie_tier2value
   ,pg.bie_tier3percent
   ,pg.bie_productsubtype
   ,pg.bie_tier1value
   ,pg.bie_tier3value
   ,pg.bie_producttype
   ,pg.bie_tier1percent
   ,p.bie_producttypenl
FROM bie_backbonus b
JOIN bie_backbonusproductgroup pg ON pg.bie_backbonuscontractno =    b.bie_backbonusid
JOIN bie_producttype p ON p.bie_name = pg.bie_producttype

在此先感谢您的帮助。

可以在 FetchXML 中嵌套 link-entity。在查看上面的查询时,您似乎在最外层同时拥有 link-entity,这解释了为什么它与 bie_backbonus 而不是您期望的 bie_backbonusproductgroup 连接。

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="bie_backbonus" enableprefiltering="1">
    <attribute name="bie_backbonuscontractno" />
    <attribute name="bie_backbonusnoteforletter" />
    <attribute name="bie_offdate" />
    <attribute name="bie_ondate" />
    <attribute name="bie_backbonuscontractversion" />
    <attribute name="bie_backbonuscontractname" />
    <attribute name="bie_backbonuscontactname" />
    <attribute name="bie_legacybackbonuscode" />
    <attribute name="owneridname" />
    <attribute name="createdon" />
<link-entity name="bie_backbonusproductgroup" from="bie_backbonuscontractno" to="bie_backbonusid" alias="pg" link-type="outer">
    <attribute name="bie_tier2percent" />
    <attribute name="bie_tier2value" />
    <attribute name="bie_tier3percent" />
    <attribute name="bie_productsubtype" />
    <attribute name="bie_tier1value" />
    <attribute name="bie_tier3value" />
    <attribute name="bie_producttype" />
    <attribute name="bie_tier1percent" />
    <!-- ↓ This has been moved inwards -->
    <link-entity name="bie_producttype" from="bie_name" to="bie_producttype" alias="p" link-type="outer">
        <attribute name="bie_producttypenl" />
    </link-entity>
    <!-- ↑ This has been moved inwards -->
 </link-entity>
  </entity>
</fetch>