Skip to content

Conversation

@cincuranet
Copy link
Contributor

Fixes #37081.
Fixes #36262.

@cincuranet cincuranet requested a review from a team as a code owner December 17, 2025 13:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the handling of Contains method calls on IReadOnlySet<T> and custom IReadOnlyCollection<T> implementations by expanding the query normalization logic to recognize Contains methods defined on IReadOnlyCollection<T> in addition to ICollection<T>.

Key Changes:

  • Extended the QueryableMethodNormalizingExpressionVisitor to detect and convert Contains calls on IReadOnlyCollection<T> types
  • Added comprehensive test coverage for IReadOnlySet<T> and custom read-only collection types with Contains methods
  • Updated SQL baselines across all provider test suites to reflect proper query translation

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/EFCore/Query/Internal/QueryableMethodNormalizingExpressionVisitor.cs Extended Contains method detection to include IReadOnlyCollection<> types alongside ICollection<>
test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs Added test methods for IReadOnlySet and ReadOnlyCollectionWithContains, plus helper class for custom read-only collection
test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs Added SQL baselines for SQLite provider showing proper IN clause generation
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs Added SQL baselines for SQL Server provider
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerJsonTypeTest.cs Added SQL baselines for SQL Server with JSON types
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServer160Test.cs Added SQL baselines for SQL Server 160 compatibility
test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs Added SQL baselines for older SQL Server versions
test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs Added SQL baselines for Cosmos DB provider using ARRAY_CONTAINS
test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs Updated baseline showing IReadOnlySet now properly uses ARRAY_CONTAINS instead of equality check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant