FetchXMLBuilder
FetchXMLBuilder copied to clipboard
[Suggestion] Invert OData URI in case when nested many-to-many relationship found in query
suggestion: There is a rule in OData endpoint: "Only many-to-one relationships are supported for nested expansion". My suggestion is to invert odata generation for case with many-to-many relationship to use on the root level of query.
Example:
OtherEntity -> Contact -> ContactAccounts <- Accounts
.
We make fetch xml:
<fetch xmlns:generator="MarkMpn.SQL4CDS" top="10">
<entity name="OtherEntity">
<link-entity name="Contact" from="ContactId" to="ContactId">
<link-entity name="ContactAccounts " from="ContactId" to="ContactId" intersect="true">
<link-entity name="Accounts" from="AccountId" to="AccountId">
....
</link-entity>
</link-entity>
</link-entity>
</link-entity>
</entity>
</fetch>
And in fetch xml builder it works. No in ODATA.
❌ Odata URI (current):
https://<...>.crm4.dynamics.com/api/data/v9.2/OtherEntity?$expand=Contact($expand=ContactAccounts ($select=....))
✔️ Odata URI (expected):
https://<...>.crm4.dynamics.com/api/data/v9.2/ContactAccounts?$expand=Contact(...),Account(...)
Hm... So you want the tool to rearrange the query "just" to make it work for OData? That's what I understand.
In that so - you should manually rearrange the query. The FetchXML Builder is supposed to be "raw" fetchxml, but easier to start building it.
Would you instead like a feature to rearrange the query when you are sure you want to? Like right-click on a link-entity (join) and say "Make this root entity" for the query.
It might be a good new feature (if I will be able to produce it 😉)