sql-server - 用于具有过滤器的 SQL 连接的 FetchXML
问题描述
我正在尝试构建与 SQL 查询等效的 FetchXML,但我对使用 FetchXML 还是很陌生:
SELECT o.opportunityid,c1.accountid
FROM dbo.opportunity o
LEFT JOIN dbo.account c1 on o.customerid = c1.accountid and o.customeridtype = 1
进入
<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”。该属性来自 SQL 查询中的机会实体。我怎样才能解决这个问题?
解决方案
我刚刚在我的一个 Dynamics 实例中触发了这个并给出了正确的结果
<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>
推荐阅读
- json - 如何将 json 文件复制到 postgres?
- javascript - 如何在 vue-slick-carousel 中更改点样式
- ios - 防止在水平集合视图上滚动
- python - 熊猫:用一个或几个 0 更新 int 系列
- node.js - 如何在另一个异步中调用异步
- php - 从 Wordpress 侧边栏(后端)隐藏特定用户角色的 GenerateBlocks Pro 链接
- date - 在 Windows 7 上为 Lingala 使用 GetDateFormatEx 时出现问题
- python - Django Rest Framework 将对象附加到多对多字段而不删除前一个
- react-native - 反应本机应用程序侧面菜单中的注销功能
- flutter - 在页面浏览中向下滚动时如何隐藏底部导航?