Hi Shalex,
here are the asked informations.
2)
New knowledge:
Exception throws only if the enum value is passed into the function.
Code: Select all
public IEnumerable<Products> Get(MyEnum type)
{
return context.Products.Where(o => o.Type == type).ToList();
}
Throws:
Code: Select all
System.InvalidOperationException occurred
HResult=-2146233079
Message=Rewriting child expression from type 'xxx.MyEnum' to type 'System.Int32' is not allowed, because it would change the meaning of the operation. If this is intentional, override 'VisitUnary' and change it to allow this rewrite.
Source=System.Core
StackTrace:
at System.Linq.Expressions.ExpressionVisitor.ValidateChildType(Type before, Type after, String methodName)
at System.Linq.Expressions.ExpressionVisitor.ValidateUnary(UnaryExpression before, UnaryExpression after)
at System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
at System.Data.Common.CommandTrees.a.VisitBinary(BinaryExpression expression)
at System.Data.Common.CommandTrees.a.b(SelectExpression A_0)
at System.Data.Common.CommandTrees.b.b(SelectExpression A_0)
at System.Data.Common.CommandTrees.a.c(SelectExpression A_0)
at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.VisitAndConvert[T](T node, String callerName)
at Devart.Data.Oracle.Entity.z.a(SelectExpression A_0)
at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.CreateDefaultQuerySqlGenerator()
at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.GetRelationalCommand(IReadOnlyDictionary`2 parameters)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.MoveNext()
at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.<_GroupJoin>d__26`4.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__22`3.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.GroupedEnumerable`3.GetEnumerator()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at xxx.<Get>d__5.MoveNext() in xxx.cs:line 60
InnerException:
SQL:
3)
Code: Select all
var productCategory = context.ProductCategories.FirstOrDefault();
var product = context.Products.Where(o => o.CategoryId == productCategory.Id).ToList();
Throws:
Code: Select all
System.InvalidOperationException occurred
HResult=-2146233079
Message=Unexpected primitive type kind 'a'.
Source=Devart.Data.Oracle.Entity.EFCore
StackTrace:
bei Devart.Common.Entity.cb.a(ck A_0)
bei Devart.Common.Entity.b.f()
bei System.Linq.Expressions.Expression.GetEqualityComparisonOperator(ExpressionType binaryType, String opName, Expression left, Expression right, Boolean liftToNull)
bei System.Linq.Expressions.Expression.Equal(Expression left, Expression right, Boolean liftToNull, MethodInfo method)
bei System.Linq.Expressions.BinaryExpression.Update(Expression left, LambdaExpression conversion, Expression right)
bei System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
bei System.Data.Common.CommandTrees.a.VisitBinary(BinaryExpression expression)
bei System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
bei System.Data.Common.CommandTrees.a.VisitBinary(BinaryExpression expression)
bei System.Linq.Expressions.ExpressionVisitor.VisitBinary(BinaryExpression node)
bei System.Data.Common.CommandTrees.a.VisitBinary(BinaryExpression expression)
bei System.Data.Common.CommandTrees.a.b(SelectExpression A_0)
bei System.Data.Common.CommandTrees.b.b(SelectExpression A_0)
bei System.Data.Common.CommandTrees.a.c(SelectExpression A_0)
bei Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.Accept(ExpressionVisitor visitor)
bei System.Linq.Expressions.ExpressionVisitor.VisitAndConvert[T](T node, String callerName)
bei Devart.Data.Oracle.Entity.z.a(SelectExpression A_0)
bei Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.CreateDefaultQuerySqlGenerator()
bei Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.GetRelationalCommand(IReadOnlyDictionary`2 parameters)
bei Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable.AsyncEnumerator.<MoveNext>d__8.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
bei Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.<_FirstOrDefault>d__82`1.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
bei Microsoft.EntityFrameworkCore.Query.Internal.TaskResultAsyncEnumerable`1.Enumerator.<MoveNext>d__3.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
bei Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.<MoveNext>d__5.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
bei xxx.<Get>d__3.MoveNext() in xxx.cs:Zeile 49.
InnerException:
SQL: