Page 1 of 1

EFCore - Disabling client evaluation

Posted: Mon 16 Oct 2017 06:53
by PeterUser
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.

Re: EFCore - Disabling client evaluation

Posted: Tue 17 Oct 2017 17:58
by Shalex
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)
[...]