如何在相同的2个实体之间的fetchXML中完成2个外连接?

时间:2012-06-26 16:26:34

标签: dynamics-crm dynamics-crm-2011

我正在尝试在fetchXML中建立2个左外连接。我可以完成这个sql语句......

select
a.new_campaignid
, a.new_ContactId
, b.new_campaigncontactstatusId
from
new_ContactCampaignNN AS a 
    left outer join new_campaigncontactstatus AS b ON a.new_contactid = b.new_ContactId 
        AND a.new_campaignid = b.new_CampaignId

进入像这样的fetchXML语句?

<fetch mapping='logical' distinct='true'>
  <entity name='new_contactcampaignnn'>
    <attribute name='new_campaignid' />
    <attribute name='new_contactid' />
    <filter type='and'>
      <condition attribute ='new_campaignid' operator='eq' value='72C9284B-905D-E111-9847-002655325864'/>
    </filter>
    <link-entity name='new_campaigncontactstatus' from='new_contactid' to='new_contactid' visible='true' link-type='outer' alias='new_contactcampaignnn_new_campaigncontactstatus'>
      <attribute name='new_campaigncontactstatusid' />
      <link-entity name='new_contactcampaignnn' from='new_campaignid' to='new_campaignid' visible='true' link-type='outer' alias='new_contactcampaignnn_new_campaigncontactstatus1'></link-entity>
    </link-entity>
  </entity>
</fetch>

1 个答案:

答案 0 :(得分:0)

我认为LINQtoCRM可以做到这一点,你可能也可以使用LinqPad