【问题标题】:How do I build FetchXML to give me all members of list A outer joined with all members of list B by emailaddress1如何构建 FetchXML 以通过 emailaddress1 为我提供列表 A 外部的所有成员与列表 B 的所有成员
【发布时间】:2014-04-06 14:37:51
【问题描述】:

这可能吗?

我已经拥有 fetch xml 来通过记录 ID 从列表 A 中过滤列表 B,但是我还想要通过电子邮件地址过滤它的选项。

例如:

列表 A 有 2 条记录。记录 1:Bob@BobMail.com 和记录 2:Susy@SusyMail.com。 列表 B 有 1 条记录。记录 3 Bob@BobMail.com 与记录 1 是不同的联系人,但具有相同的电子邮件地址。

还和我在一起吗?很抱歉解释混乱...

查询应采用列表 A,与列表 B 进行外部连接以生成仅包含记录 2 和电子邮件地址 Susy@SusyMail.com 的结果。

如果有什么方法可以让我更清楚自己想要做什么,请不要犹豫。

【问题讨论】:

  • 在我看来,您想要执行相当于 T-SQL EXCEPT 的操作。不幸的是,这在 fetchxml 查询中是不可能的。但是,您也许可以在两个 fetchxml 查询结果上使用 c# except 扩展方法来实现相同的结果...
  • 该逻辑在 ID 级别起作用。如果记录 1 和记录 3 (Bob@BobMail.com) 是同一记录,它将正确排除他。我正在尝试对电子邮件做同样的事情。我希望我没有完全不走运......

标签: c# dynamics-crm email-address fetchxml


【解决方案1】:

经过一夜的思考和早上一双新的眼睛,我意识到我只需要将列表成员链接到联系人,就像我使用 by ID 选项一样,然后添加一个额外的链接到联系人电子邮件地址上的实体。

<fetch mapping="logical" version="1.0" page="1" count="100" >
<entity name="contact" >
    <link-entity name="listmember" from="entityid" to="contactid" >
        <filter>
            <condition attribute="listid" operator="eq" value="06197bff-a299-e311-aae4-6c3be5a892e8" />
        </filter>
    </link-entity>
    <attribute name="contactid" />
    <attribute name="emailaddress1" />
    <filter type="and" >
        <condition attribute="emailaddress1" operator="not-null" />
        <condition attribute="donotbulkemail" operator="ne" value="1" />
    </filter>
    <link-entity name="listmember" from="entityid" to="contactid" link-type="outer" alias="exclusionlist" >
        <attribute name="entityid" />
        <filter type="and" >
            <condition attribute="listid" operator="eq" value="06197bff-a299-e311-aae4-6c3be5a892e8" />
        </filter>
    </link-entity>
    <link-entity name="contact" from="emailaddress1" to="emailaddress1" link-type="outer" alias="emailaddress" >
        <attribute name="fullname" />
        <attribute name="emailaddress1" />
    </link-entity>
    <order descending="false" attribute="emailaddress1" />
</entity>

然后我们通过别名过滤掉结果:'

        results = results.Where(x => !x.Contains("exclusionlist.entityid") || !x.Contains("emailaddress.emailaddress1")).ToList();

希望这对其他人有所帮助,尽管我现在确实觉得问起来有点愚蠢......

【讨论】:

    猜你喜欢
    • 2015-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-15
    相关资源
    最近更新 更多