3 Replies Latest reply on Jun 23, 2020 5:53 PM by Alex Keh - Product Manager-Oracle

    EF Core 3.1 beta - Error casting Enum inside Where Clause


      After migrating to Oracle EF Core 3.19.0-beta I'm getting an error when casting an enum inside a Where clause:


      private static EmailTemplate GetTemplate(TemplateType templateType)


                  return _context.FinancialEmailTemplate

                      .Where(t => t.Code == (int)templateType)




      The error only happens when the Enum is a parameter of the function. If the where clause is like


      .Where(t => t.Code == (int)TemplateType.MultipleBillets)


      the query works. Also works fine if I assign the parameter to a local variable.


      The StackTrace:



          System.ArgumentException : Value does not fall within the expected range.

        Stack Trace:

          OracleParameter.set_Value(Object value)

          RelationalTypeMapping.CreateParameter(DbCommand command, String name, Object value, Nullable`1 nullable)

          TypeMappedRelationalParameter.AddDbParameter(DbCommand command, Object value)

          RelationalParameterBase.AddDbParameter(DbCommand command, IReadOnlyDictionary`2 parameterValues)

          OracleRelationalCommand.CreateCommand(RelationalCommandParameterObject parameterObject, Guid commandId, DbCommandMethod commandMethod)

          OracleRelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)

          Enumerator.InitializeReader(DbContext _, Boolean result)

          OracleExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)


          Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)

          QueryCompiler.Execute[TResult](Expression query)

          EntityQueryProvider.Execute[TResult](Expression expression)

          Queryable.FirstOrDefault[TSource](IQueryable`1 source)