Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CosmosDB Provider Support Any(condition) on Nested Collection by mapping to ARRAY_CONTAINS #32626

Open
drdamour opened this issue Dec 15, 2023 · 0 comments

Comments

@drdamour
Copy link

i looked around for another issue on this..was pretty shocked i couldn't find it, maybe my lingo/terms are all wrong. #14762 seemed like a subcase of what i was execpting to find. #20441 is another special case...well it's Any() and i'm after Any(boolCondition)

given

public class OrderReleaseEvent
{
    
    public string Href { get; set; }
}

public class Order
{
  public string Number { get; set; }
  public ICollection<OrderReleaseEvent> OrderReleaseEvents { get; set; } = new List<OrderReleaseEvent>();
}


 var results = awai db.Orders
            .Where(
                o => o.OrderReleaseEvents.Any(
                    e => e.Href == "https://example.com/events/b8f39c16-23da-4cf7-a71d-de5c859d0484"
                )
            )
            .ToListAsync();

should match a document like this

{    
    "Number": "00700-10935701",
    "_etag": "\"0900e9f8-0000-0800-0000-657c888c0000\"",
    "OrderReleaseEvents": [
        {
            "Href": "https://example.com/events/b8f39c16-23da-4cf7-a71d-de5c859d0484",
        }
    ]
}
            

The provider should translate this query into

SELECT * FROM c
WHERE Array_contains(c.OrderReleaseEvents, {"Href" : "https://example.com/events/b8f39c16-23da-4cf7-a71d-de5c859d0484"}, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants