Skip to content

Conversation

Copy link

Copilot AI commented Sep 10, 2025

This PR implements support for the NotAny join operator in XrmMockup Query Expression, addressing the limitation where only LeftOuter join was previously supported.

What was implemented

The NotAny join operator provides anti-join functionality, returning records from the primary entity that do NOT have matching records in the linked entity.

Key changes:

  1. FetchXML parsing support - Added "notany" link-type parsing in XmlHandling.cs:

    <link-entity name='lead' from='parentcontactid' to='contactid' link-type='notany' />
  2. Query Expression support - Added JoinOperator.NotAny handling in RetrieveMultipleRequestHandler.cs:

    var linkEntity = new LinkEntity() {
        JoinOperator = JoinOperator.NotAny,
        // ... other properties
    };
  3. Anti-join logic - Implemented proper NotAny behavior:

    • Returns parent entity when no matching linked entities are found
    • Returns nothing when matching linked entities are found

Example usage

// Find contacts that do NOT have any associated leads
var query = new QueryExpression("contact") {
    ColumnSet = new ColumnSet("contactid", "lastname")
};

query.LinkEntities.Add(new LinkEntity() {
    LinkToEntityName = "lead",
    LinkToAttributeName = "parentcontactid", 
    LinkFromEntityName = "contact",
    LinkFromAttributeName = "contactid",
    JoinOperator = JoinOperator.NotAny
});

var contactsWithoutLeads = orgService.RetrieveMultiple(query);

Testing

Added comprehensive test coverage including both QueryExpression and FetchXML scenarios. The implementation follows the same patterns as existing join operators and maintains full backward compatibility.

Fixes #280.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Author

Copilot AI commented Sep 10, 2025

@KristianKlodeD 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: KristianKlodeD <128026855+KristianKlodeD@users.noreply.github.com>
Copilot AI changed the title [WIP] No support for testing join operator NotAny when using Query Expression Add support for NotAny join operator in Query Expression Sep 10, 2025
Copy link

@KristianKlodeD KristianKlodeD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the files committed with only a path to another file with the same name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No support for testing join operator NotAny when using Query Expression

2 participants