Add EF.Functions.JsonContains for SQL Server 2025#37714
Open
roji wants to merge 1 commit intodotnet:mainfrom
Open
Add EF.Functions.JsonContains for SQL Server 2025#37714roji wants to merge 1 commit intodotnet:mainfrom
roji wants to merge 1 commit intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR exposes SQL Server 2025’s JSON_CONTAINS() via a new EF.Functions.JsonContains API, adds query translation for it, and updates/extends functional tests to validate the new translation against the native SQL Server json type behavior.
Changes:
- Added
SqlServerDbFunctionsExtensions.JsonContains(...)(marked[Experimental]) and wired up translation toJSON_CONTAINSin the SQL Server query translator. - Added new SQL Server translation tests for
EF.Functions.JsonContainsover scalar/complex/owned JSON properties and adjusted JSON string assertions to tolerate DB normalization. - Updated JSON-type update test baselines to reflect new parameter sizing behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/EFCore.SqlServer.FunctionalTests/Update/JsonUpdateJsonTypeSqlServerTest.cs | Updates SQL baseline expectations for JSON-type parameter sizes. |
| test/EFCore.SqlServer.FunctionalTests/Query/Translations/JsonTranslationsSqlServerTest.cs | Adds JsonContains translation tests and configures JsonString to use json type under SQL Server 2025+. |
| test/EFCore.Relational.Specification.Tests/Query/Translations/JsonTranslationsRelationalTestBase.cs | Compares JSON strings via DOM to avoid failures due to DB JSON normalization. |
| src/Shared/EFDiagnostics.cs | Adds a new diagnostic ID for the experimental JsonContains API. |
| src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs | Implements translation of EF.Functions.JsonContains to JSON_CONTAINS. |
| src/EFCore.SqlServer/Extensions/SqlServerDbFunctionsExtensions.cs | Introduces the public EF.Functions.JsonContains API stub (experimental). |
test/EFCore.SqlServer.FunctionalTests/Query/Translations/JsonTranslationsSqlServerTest.cs
Outdated
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs
Show resolved
Hide resolved
src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs
Show resolved
Hide resolved
test/EFCore.SqlServer.FunctionalTests/Query/Translations/JsonTranslationsSqlServerTest.cs
Outdated
Show resolved
Hide resolved
test/EFCore.SqlServer.FunctionalTests/Query/Translations/JsonTranslationsSqlServerTest.cs
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continues #37562
Closes #37566