I want to get data from two tables deal and details. I could make join and fetch data but I couldn't figure out how to link-entity on a condition. In simple terms, I want
if deal.sell is yes:
fetch details
else:
fetch deal
The xml below links and fetches some attributes of details , how can I insert the if else clause to this?(if its possible)
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='deal'>
<attribute name='createdon' />
<attribute name='statecode' />
<attribute name='dealsid' />
<link-entity name='details' from='detailsid' to='deal_detail' >
<attribute name='description' />
</link-entity>
</entity>
</fetch>
There is no way of doing that using FetchXml. You will have to think about other way of implementing your requirement.
You deal with this by having multiple joins, one for each if/else
Using Pesduo code:
From deal
Outer Join Details on Deal.Id = Details.Id
Outer Join Deal on Deal.Id = Deal.ParentDealId
Then you'd do the work on the client side to figure out what you need, and what you don't.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.