c# - 避免 FetchXml 结果中的别名与链接实体
问题描述
我有以下 FetchXML:
<fetch>
<entity name="list" >
<attribute name="listname" />
<attribute name="listid" alias="List" />
<filter type="and" >
<condition attribute="listname" operator="eq" value="Test 1" />
</filter>
<link-entity name="listmember" from="listid" to="listid" intersect="true" alias="listmember" >
<attribute name="entitytype" />
<attribute name="listmemberid" />
<attribute name="entityid" />
<link-entity name="contact" from="contactid" to="entityid" alias="contact" >
<attribute name="contactid" />
<attribute name="owneridname" />
<attribute name="owneridtype" />
<attribute name="ownerid" />
</link-entity>
</link-entity>
</entity>
结果如下所示:
<resultset morerecords="0" paging-cookie="<cookie page="1"><listid lastnull="1" firstnull="1" /></cookie>">
<result>
<listname>Test 1</listname>
<listmember.entitytype formattedvalue="2">2</listmember.entitytype>
<listmember.listmemberid>{6739D9B9-xxxx-xxxx-xxxx-000D3A3852A3}</listmember.listmemberid>
<listmember.entityid type="2">{039FD4C6-xxxx-xxxx-xxxx-000D3A385A1C}</listmember.entityid>
<contact.contactid>{039FD4C6-xxxx-xxxx-xxxx-000D3A385A1C}</contact.contactid>
<contact.ownerid name="CRM Test" dsc="" type="8" yomi="CRM Test">{5ABA5CBA-xxxx-xxxx-xxxx-D472F64781F6}</contact.ownerid>
</result>
</resultset>
我现在的问题是我有一种通用的方法来检索 FetchXml 返回的属性。但是由于这个已经链接了实体,所以别名被添加到结果中,例如:
<listmember.listmemberid>
所以我的检索会抛出一个错误,因为我正在寻找“listmemberid”
有没有办法避免将这些别名添加到结果中?特别是因为属性名称是唯一的?
有什么想法可以解决这个问题吗?
解决方案
您获得了这些别名,然后它就有价值了,因为您正在从链接实体中检索数据。每当您这样做时,即从链接实体中检索,您将不得不使用别名,据我所知您无法规避它。
我可以建议的是,如果您只需要来自 ListMember 实体而不是来自 List 和联系人的数据,请根据列表成员实体创建您的提取,例如
select * from listmember where listname="Test 1"
但是,一旦您需要来自相关实体的数据,该相关实体就会被别名。
推荐阅读
- c# - 1.路由参数中的正斜杠
- view - Magento 2:如何为同一国家/地区的多个商店创建不同的税率
- excel - 有没有办法在不使用 excel 代码的情况下更改单元格文本颜色?
- flutter - 颤振未找到:'package:html/parser.dart
- google-apps-script - 谷歌表格日期戳脚本不起作用
- reactjs - 在 React.js/Next.js 组合中访问 JSON 数组数据
- java - 如何在不使用 servlet 中的任何脚本的情况下发送表行数据?
- c++ - 将函数参数 `const char*` 转换为 `std::string_view` 是否安全?
- javascript - javascript如何从select-option中的相同类名中收集值?
- dynamic - 表行表达式的动态 ASSIGN