You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -325,7 +325,7 @@ For more information, see the [full documentation on full-text search](xref:core
325
325
326
326
<aname="sql-server-json-contains"></a>
327
327
328
-
### Translate Contains over primitive collections using JSON_CONTAINS
328
+
### Contains operations using JSON_CONTAINS
329
329
330
330
SQL Server 2025 introduced the [`JSON_CONTAINS`](/sql/t-sql/functions/json-contains-transact-sql) function, which checks whether a value exists in a JSON document. Starting with EF Core 11, when targeting SQL Server 2025, LINQ `Contains` queries over primitive (or scalar) collections stored as JSON are translated to use this function, replacing the previous, less efficient `OPENJSON`-based translation.
331
331
@@ -368,3 +368,27 @@ WHERE JSON_CONTAINS([b].[Tags], 'ef-core') = 1
368
368
369
369
> [!NOTE]
370
370
> `JSON_CONTAINS` does not support searching for null values. As a result, this translation is only applied when EF can determine that at least one side is non-nullable — either the item being searched for (e.g. a non-null constant or a non-nullable column), or the collection's elements. When this cannot be determined, EF falls back to the previous `OPENJSON`-based translation.
371
+
372
+
#### EF.Functions.JsonContains()
373
+
374
+
In the section above, EF Core automatically translates LINQ `Contains` queries over primitive collections to use the SQL Server `JSON_CONTAINS` function. In some cases, however, you may want to directly invoke `JSON_CONTAINS` yourself, for example to search for a value at a specific path, or to specify a search mode. For these cases, EF Core 11 introduces `EF.Functions.JsonContains()`.
375
+
376
+
The following query checks whether a blog's JSON data contains a specific value at a given path:
WHERE JSON_CONTAINS([b].[JsonData], 8, N'$.Rating') =1
390
+
```
391
+
392
+
`EF.Functions.JsonContains()` accepts the JSON value to search in, the value to search for, and optionally a JSON path and a search mode. It can be used with scalar string properties, complex types, and owned entity types mapped to JSON columns.
393
+
394
+
For the full `JSON_CONTAINS` SQL Server documentation, see [`JSON_CONTAINS`](/sql/t-sql/functions/json-contains-transact-sql).
0 commit comments