1:多くの関係を取得するために、単一のfetchxmlクエリを書くことができますか?
-
03-10-2019 - |
質問
ルートエンティティと複数の子供を取得する単一のfetchxmlクエリを書くことは可能ですか?私ができることは1:1だけです。
解決
いいえ、不可能です。
他のヒント
ジェームズ・ウッドは正しいです. 。 Fetch XMLは再帰的であるため、リンクエンティティを使用することで、必要な情報を取得できます。
たとえば、以下は有効です。
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="account">
<attribute name="name" />
<attribute name="primarycontactid" />
<attribute name="telephone1" />
<attribute name="accountid" />
<order attribute="name" descending="false" />
<link-entity name="contact" from="parentcustomerid" to="accountid" alias="aj">
<attribute name="firstname" />
<attribute name="lastname" />
<attribute name="telephone1" />
<link-entity name="businessunit" from="businessunitid" to="owningbusinessunit" alias="ak">
<attribute name="name" />
<attribute name="address1_line1" />
<attribute name="address1_line2" />
<attribute name="address1_line3" />
<filter type="and">
<condition attribute="name" operator="not-null" />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>
あなたの質問が本当にある場合、「 独身 ルートエンティティと複数の子供」と答えは残念ながらノーです。ただし、ルートデータの重複を処理できれば(たとえば、SSRSレポートのグループ化機能を使用するなど)、必要なものは完全に可能です
私が質問を誤解していない限り、これは非常に可能です。
たとえば、特定のアカウントに関連するすべての連絡先を見つけたいと思います。これは、アカウントへの連絡先の親の顧客検索によってCRMで表されます。
<fetch mapping="logical" count="100" version="1.0">
<entity name="account">
<attribute name="name" />
<link-entity name="contact" from="parentcustomerid" to="accountid">
<attribute name="fullname" />
</link-entity>
</entity>
</fetch>
これにより、次のような結果セットが得られます。
<resultset morerecords="0" paging-cookie="<cookie page="1"><accountid last="{E704FAD6-2D4B-E111-9FED-00155D828444}" first="{AD912122-6B3C-E111-9B37-00155D828444}" /></cookie>">
<result>
<name>RGD Mining Inc</name>
<accountid>{E704FAD6-2D4B-E111-9FED-00155D828444}</accountid>
<accountid.fullname>Bill Miner</accountid.fullname>
</result>
<result>
<name>RGD Mining Inc</name>
<accountid>{E704FAD6-2D4B-E111-9FED-00155D828444}</accountid>
<accountid.fullname>Green</accountid.fullname>
</result>
</resultset>
それが可能であると報告してうれしいです。私にはうまくいったソリューションがあります。
唯一の注意点は、複数の子アカウントがある場合、親に対して複数の結果が得られるということです。例えば:
parent 1: child 1
parent 2: child 1
parent 2: child 2
これは、並べ替え関数を介して結果を実行し、すべての子供をマルチディメンション配列で取得するか、すべてのアカウントをフラット配列の一意のエントリとして取得する必要があることを意味します。
また、これは1つのレベルのみ下がっています。階層がマルチレベルの場合、このコードを変更する必要があります。
<fetch distinct="false" mapping="logical">
<entity name="account">
<attribute name="name" />
<link-entity name="account" alias="childaccount" to="accountid" from="parentaccountid" link-type="outer">
<attribute name="name" alias="childname" />
</link-entity>
</entity>
</fetch>
所属していません StackOverflow