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
In EF Core 9 and earlier, parameterized collections in LINQ queries (such as those used with `.Contains()`) were translated to SQL using a JSON array parameter by default. Consider the following query:
FROM OPENJSON(@__ids_0) WITH ([value] int'$') AS [i]
161
+
)
162
+
```
163
+
164
+
#### New behavior
165
+
166
+
Starting with EF Core 10.0, parameterized collections are now translated using multiple scalar parameters by default:
167
+
168
+
```sql
169
+
SELECT [b].[Id], [b].[Name]
170
+
FROM [Blogs] AS [b]
171
+
WHERE [b].[Id] IN (@ids1, @ids2, @ids3)
172
+
```
173
+
174
+
#### Why
175
+
176
+
The new default translation provides the query planner with cardinality information about the collection, which can lead to better query plans in many scenarios. The multiple parameter approach balances between plan cache efficiency (by parameterizing) and query optimization (by providing cardinality).
177
+
178
+
However, different workloads may benefit from different translation strategies depending on collection sizes, query patterns, and database characteristics.
179
+
180
+
#### Mitigations
181
+
182
+
If you encounter issues with the new default behavior (such as performance regressions), you can configure the translation mode globally:
For more information about parameterized collection translation, [see the documentation](xref:core/what-is-new/ef-core-10.0/whatsnew#parameterized-collection-translation).
217
+
135
218
<aname="ExecuteUpdateAsync-lambda"></a>
136
219
137
220
### ExecuteUpdateAsync now accepts a regular, non-expression lambda
0 commit comments