dotnet / dotnet/efcore

Cosmos: Set operations over embedded collections

Open
#37,918 1 comment 1 reaction 0 assignees View on GitHub
area-cosmos area-query customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

### What problem are you trying to solve?

Performing a Union, Intersect, Except or Concat over owned or complex collections or projections thereof

https://learn.microsoft.com/en-us/cosmos-db/query/setunion
https://learn.microsoft.com/en-us/cosmos-db/query/setintersect
https://learn.microsoft.com/en-us/cosmos-db/query/array-concat

### Describe the solution you'd like

EF could translate
```csharp
ss.Set().Select(e =>
e.AssociateCollection.Where(r => r.Int == 8)
.Concat(e.AssociateCollection.Where(r => r.String == "foo"))
```
To
```sql
SELECT VALUE ARRAY_CONCAT(
ARRAY(SELECT VALUE r FROM r IN c.AssociateCollection WHERE r.Int == 8),
ARRAY(SELECT VALUE r FROM r IN c.AssociateCollection WHERE r.String == "foo")
)
FROM c
```
I think this could be quite expensive RU wise since it's scanning 2 and allocating 3 arrays, but it is a possible way.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.