我有两个不相关的表,但是有一个共同的列。我想加入表B中与表A中的<attribute name='substitutedproductid'>
匹配的行。表A看起来像这样:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="productsubstitute">
<attribute name='substitutedproductid' />
<attribute name='new_quantity' />
<attribute name='new_unit' />
<attribute name='new_grouping' />
<filter type="and">
<condition attribute="productid" operator="eq" value="{guid}" />
</filter>
</entity>
</fetch>
表B看起来像这样:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="new_contractlinedislike">
<attribute name="new_contractlinedislikeid" />
<attribute name="substituteproductid" />
<attribute name="new_unit" />
<attribute name="new_quantity />
<attribute name="new_grouping" />
<filter type="and">
<condition attribute="new_contractlineid" operator="eq" value="{guid}" />
</filter>
</entity>
</fetch>
如上所示,两个表都有一个查找(substituteproductid),该查找可以是同一产品。在查找相同的情况下,我想对表A进行左连接。基本上,我想从单个fetchXml字符串中返回单个实体集合。我该如何实现?
答案 0 :(得分:1)
基本上,您必须使用link-entity
。此查询应适用于您的方案。 Referred the old discussion.
<fetch version='1.0' output-format='xml-platform' mapping='logical' >
<entity name= 'productsubstitute' >
<attribute name='new_quantity' />
<attribute name='new_unit' />
<attribute name='new_grouping' />
<filter type='and' >
<condition attribute='productid' operator='eq' value= '{guid}' />
</filter>
<link-entity name='new_contractlinedislike' from='substitutedproductid' to='substituteproductid' link-type='outer' >
<attribute name='new_contractlinedislikeid' />
<attribute name= 'new_grouping' />
<filter type='and' >
<condition attribute='new_contractlineid' operator='eq' value= '{guid}' />
</filter>
</link-entity>
</entity>
</fetch>