Skip to content

Commit

Permalink
Enable buffering for split queries
Browse files Browse the repository at this point in the history
Otherwise MARS is assumed by EF Core, which we don't support.

See dotnet/efcore#21420

(cherry picked from commit ab5d62a)
  • Loading branch information
roji committed Jun 26, 2020
1 parent 075f4a4 commit 5074252
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static IServiceCollection AddEntityFrameworkNpgsql([NotNull] this IServic
.TryAdd<ISqlExpressionFactory, NpgsqlSqlExpressionFactory>()
.TryAdd<ISingletonOptions, INpgsqlOptions>(p => p.GetService<INpgsqlOptions>())
.TryAdd<IValueConverterSelector, NpgsqlValueConverterSelector>()
.TryAdd<IQueryCompilationContextFactory, NpgsqlQueryCompilationContextFactory>()
.TryAddProviderSpecificServices(
b => b
.TryAddSingleton<INpgsqlValueGeneratorCache, NpgsqlValueGeneratorCache>()
Expand Down
17 changes: 17 additions & 0 deletions src/EFCore.PG/Query/Internal/NpgsqlQueryCompilationContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Query;

namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query.Internal
{
public class NpgsqlQueryCompilationContext : RelationalQueryCompilationContext
{
public NpgsqlQueryCompilationContext(
[NotNull] QueryCompilationContextDependencies dependencies,
[NotNull] RelationalQueryCompilationContextDependencies relationalDependencies, bool async)
: base(dependencies, relationalDependencies, async)
{
}

public override bool IsBuffering => base.IsBuffering || IsSplitQuery;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Query;
using Npgsql.EntityFrameworkCore.PostgreSQL.Utilities;

namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query.Internal
{
public class NpgsqlQueryCompilationContextFactory : IQueryCompilationContextFactory
{
readonly QueryCompilationContextDependencies _dependencies;
readonly RelationalQueryCompilationContextDependencies _relationalDependencies;

public NpgsqlQueryCompilationContextFactory(
[NotNull] QueryCompilationContextDependencies dependencies,
[NotNull] RelationalQueryCompilationContextDependencies relationalDependencies)
{
Check.NotNull(dependencies, nameof(dependencies));
Check.NotNull(relationalDependencies, nameof(relationalDependencies));

_dependencies = dependencies;
_relationalDependencies = relationalDependencies;
}

public virtual QueryCompilationContext Create(bool async)
=> new NpgsqlQueryCompilationContext(_dependencies, _relationalDependencies, async);
}
}

0 comments on commit 5074252

Please sign in to comment.