EFCore - Disabling client evaluation

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
PeterUser
Posts: 36
Joined: Mon 27 Feb 2017 07:45

EFCore - Disabling client evaluation

Post by PeterUser » Mon 16 Oct 2017 06:53

Hi,

I am using EF Core with dotConnect for Oracle as a database provider. I see that many queries are executed in code. The EF Core documentation lists the possibility to configure the provider to throw an exception, when this happens.

Code: Select all

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    optionsBuilder
        .UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFQuerying;Trusted_Connection=True;")
        .ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning));
}
Is there something like this for the dotConnect for Oracle provider?

It is very cumbersome to check every query by hand.

Greetings
Peter

I use EF Core 1.1.2 with dotConnect for Oracle 9.4.326.

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: EFCore - Disabling client evaluation

Post by Shalex » Tue 17 Oct 2017 17:58

The same option works with dotConnect for Oracle as well:

Code: Select all

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    optionsBuilder
        .UseOracle(@"...")
        .ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning));
}
[...]
    var groups = context.DEPTs
                    .GroupBy(groupBy => groupBy.DEPTNO)
                    .Select(g => g.Count())
                    .ToList();
->
System.InvalidOperationException occurred
  HResult=0x80131509
  Message=Warning as error exception for warning 'RelationalEventId.QueryClientEvaluationWarning': The LINQ expression 'GroupBy([groupBy].DEPTNO, [groupBy])' could not be translated and will be evaluated locally. To suppress this Exception use the DbContextOptionsBuilder.ConfigureWarnings API. ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider.
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at Microsoft.EntityFrameworkCore.Internal.InterceptingLogger`1.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   at Microsoft.EntityFrameworkCore.Infrastructure.SensitiveDataLogger`1.Microsoft.Extensions.Logging.ILogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalLoggerExtensions.LogWarning(ILogger logger, RelationalEventId eventId, Func`1 formatter)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.WarnClientEval(Object expression)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, Int32 index)
   at Remotion.Linq.QueryModelVisitorBase.VisitResultOperators(ObservableCollection`1 resultOperators, QueryModel queryModel)
   at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)
   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel(QueryModel queryModel)
   at Devart.Data.Oracle.Entity.y.a(QueryModel A_0)
[...]

Post Reply