D365实现关联实体之间的条件或者关系例子:
下面的示例查询客户列表,条件是:
客户的状态=可用且((客户库存的某些产品在指定列表中,且状态=100000001) 或者某些产品不在客户库存表中)
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >
<entity name="account" >
<attribute name="name" />
<attribute name="accountid" />
<order attribute="name" descending="false" />
<filter type="and" >
<condition attribute="statecode" operator="eq" value="0" />
</filter>
<filter type="or" >
<condition entityname="acnull" attribute="account_r1" operator="null" />
<condition entityname="acoffshelf" attribute="onshelfstatus" operator="eq" value="100000001" />
</filter>
<link-entity name="accountstock" from="account_r1" to="accountid" link-type="outer" alias="acoffshelf" >
<filter type="and" >
<condition attribute="product_r2" operator="in" >
<value>6a7644c6-540f-ee11-8f6e-6045bd1ba93b</value>
</condition>
</filter>
</link-entity>
<link-entity name="accountstock" from="account_r1" to="accountid" link-type="outer" alias="acnull" >
<filter type="and" >
<condition attribute="product_r2" operator="in" ><value>6a7644c6-540f-ee11-8f6e-6045bd1ba93b</value>
</condition>
</filter>
</link-entity>
</entity>
</fetch>