首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FetchXML for SQL Join having filter

FetchXML for SQL Join having filter
EN

Stack Overflow用户
提问于 2020-02-19 20:22:12
回答 2查看 241关注 0票数 1

我正在尝试构建与SQL query等价物的FetchXML,我对FetchXML的使用非常陌生:

代码语言:javascript
复制
SELECT o.opportunityid,c1.accountid
FROM dbo.opportunity o
LEFT JOIN dbo.account c1 on o.customerid = c1.accountid and o.customeridtype = 1 

转到

代码语言:javascript
复制
<fetch mapping="logical" version="1.0">
  <entity name="opportunity">
  <attribute name="opportunityid" />
    <link-entity name="account" from="accountid" to="customerid" alias="A1" link-type="outer" >
        <filter type="and" >
            <condition attribute="customeridtype" operator="eq" value="1" />
        </filter>
    <attribute name="accountid" /> 
    </link-entity>

但这是抛出错误,说属性"customeridtype“不存在于实体"account”中。该属性来自SQL查询中的opportunity实体。我该如何解决这个问题呢?

EN

回答 2

Stack Overflow用户

发布于 2020-02-19 21:13:42

我刚刚在我的一个Dynamics实例中触发了这个,并给出了正确的结果

代码语言:javascript
复制
<fetch>
      <entity name="opportunity" >
        <attribute name="opportunityid" />
        <attribute name="customeridtype" />
        <filter type="and" >
          <condition attribute="customeridtype" operator="eq" value="1" />
        </filter>
        <link-entity name="account" from="accountid" to="customerid" link-type="outer" alias="Account" >
          <attribute name="accountid" alias="AccountId" />
        </link-entity>
      </entity>
    </fetch>
票数 0
EN

Stack Overflow用户

发布于 2020-02-19 21:17:58

从内部link-entity xml节点到外部entity节点取出filter

你可以试试XrmToolBox fetchxml builder或者Kingswaysoft sql2fetchxml在线工具。

代码语言:javascript
复制
<fetch mapping="logical" version="1.0">
  <entity name="opportunity">
  <attribute name="opportunityid" />

    <filter type="and" >
        <condition attribute="customeridtype" operator="eq" value="1" />
    </filter>

    <link-entity name="account" from="accountid" to="customerid" alias="A1" link-type="outer" >
        <attribute name="accountid" />   
    </link-entity> 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60300296

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档