Skip to content

Commit 9be9eca

Browse files
committed
Disable MultipleParameters for now
See #3269
1 parent 8332c31 commit 9be9eca

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,25 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal;
1111
public class NpgsqlOptionsExtension : RelationalOptionsExtension
1212
{
1313
private DbContextOptionsExtensionInfo? _info;
14+
private ParameterizedCollectionMode? _parameterizedCollectionMode;
15+
1416
private readonly List<UserRangeDefinition> _userRangeDefinitions;
1517
private readonly List<EnumDefinition> _enumDefinitions;
16-
1718
private Version? _postgresVersion;
1819

20+
// We override ParameterizedCollectionMode to set Parameter as the default instead of MultipleParameters,
21+
// which is the EF relational default. In PostgreSQL using native array parameters is better, and the
22+
// query plan problem can be mitigated by telling PostgreSQL to use a custom plan (see #3269).
23+
24+
/// <summary>
25+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
26+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
27+
/// any release. You should only use it directly in your code with extreme caution and knowing that
28+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
29+
/// </summary>
30+
public override ParameterizedCollectionMode ParameterizedCollectionMode
31+
=> _parameterizedCollectionMode ?? ParameterizedCollectionMode.Parameter;
32+
1933
/// <summary>
2034
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
2135
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
@@ -132,6 +146,17 @@ public NpgsqlOptionsExtension(NpgsqlOptionsExtension copyFrom)
132146
public override int? MinBatchSize
133147
=> base.MinBatchSize ?? 2;
134148

149+
// We need to override WithUseParameterizedCollectionMode since we override ParameterizedCollectionMode above
150+
/// <inheritdoc />
151+
public override RelationalOptionsExtension WithUseParameterizedCollectionMode(ParameterizedCollectionMode parameterizedCollectionMode)
152+
{
153+
var clone = (NpgsqlOptionsExtension)Clone();
154+
155+
clone._parameterizedCollectionMode = parameterizedCollectionMode;
156+
157+
return clone;
158+
}
159+
135160
/// <summary>
136161
/// Creates a new instance with all options the same as for this instance, but with the given option changed.
137162
/// It is unusual to call this method directly. Instead use <see cref="DbContextOptionsBuilder" />.

0 commit comments

Comments
 (0)