Cosmos: Set operations over embedded collections
- 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
Assessment
This issue has not been assessed yet.