如何构建FetchXML以通过emailaddress1为列表A的所有成员加入列表A的所有成员

时间:2014-03-04 20:36:44

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

甚至可能吗?

我已经通过记录ID过滤了列表A中的提取xml,但是我还希望选择按电子邮件地址过滤它。

例如:

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

还在我身边吗?很抱歉这个令人困惑的解释...

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

如果有什么方法可以让我更清楚我要做的事情,请不要犹豫。

1 个答案:

答案 0 :(得分:1)

在一个晚上想到它和一双清新的眼睛在早上我意识到我只需要将列表成员链接到联系人,就像我使用ID 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();

希望这有助于其他人,虽然我现在觉得有点愚蠢......