dotnet / dotnet/efcore

Use JSON_CONTAINS() to translate JSON array containment

Open
#37,565 2 comments 1 reaction 0 assignees View on GitHub
area-json area-perf area-query area-sqlserver blocked consider-for-next-release
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

According to the [`JSON_CONTAINS()` docs](https://learn.microsoft.com/en-us/sql/t-sql/functions/json-contains-transact-sql?view=sql-server-ver17):

> A JSON array search value is contained in a target array if and only if every element in the search array is contained in some element of the target array.

This means we should be able to use it to translate `jsonArray1.subset.All(s => jsonArray2.Contains(s))` (array containment).

However, at the time of writing, the `json` type isn't supported as search value (see limitations). Also keep in mind the problematic null behavior of JSON_CONTAINS(), i.e. specifically check what happens if the contained array has nulls.

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.