EF6 Compatibility - $filter ; $select does not work
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
I used the sample "ODataRoutingSample" and replaced EF-Core with EF6.
It generally works until you use "Queryable Features" like $filter or $select then you will recive this expcetion:
NotSupportedException: Unable to create a constant value of type 'Microsoft.OData.Edm.IEdmModel'. Only primitive types or enumeration types are supported in this context.
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+ConstantTranslator.TypedTranslate(ExpressionConverter parent, ConstantExpression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+TypedTranslator<T_Linq>.Translate(ExpressionConverter parent, Expression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MemberInitTranslator.TypedTranslate(ExpressionConverter parent, MemberInitExpression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+TypedTranslator<T_Linq>.Translate(ExpressionConverter parent, Expression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input, out DbExpressionBinding binding)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator+OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, out DbExpression source, out DbExpressionBinding sourceBinding, out DbExpression lambda)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator+SelectTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator+SequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, SequenceMethod sequenceMethod)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+TypedTranslator<T_Linq>.Translate(ExpressionConverter parent, Expression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateSet(Expression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator+UnarySequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator+SequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, SequenceMethod sequenceMethod)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter+TypedTranslator<T_Linq>.Translate(ExpressionConverter parent, Expression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.Convert()
System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable forMergeOption)
System.Data.Entity.Core.Objects.ObjectQuery+<>c__DisplayClass41_0.b__1()
System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction(Func func, IDbExecutionStrategy executionStrategy, bool startLocalTransaction, bool releaseConnectionOnSuccess)
System.Data.Entity.Core.Objects.ObjectQuery+<>c__DisplayClass41_0.b__0()
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func operation)
System.Data.Entity.Core.Objects.ObjectQuery.GetResults(Nullable forMergeOption)
System.Data.Entity.Core.Objects.ObjectQuery.<System.Collections.Generic.IEnumerable.GetEnumerator>b__31_0()
System.Data.Entity.Internal.LazyEnumerator.MoveNext()
System.Collections.Generic.List..ctor(IEnumerable collection)
Microsoft.AspNetCore.OData.Query.Container.TruncatedCollection..ctor(IQueryable source, int pageSize, bool parameterize) in TruncatedCollectionOfT.cs
: base(Take(source, pageSize, parameterize))
Microsoft.AspNetCore.OData.Query.ODataQueryOptions.LimitResults(IQueryable queryable, int limit, bool parameterize, out bool resultsLimited) in ODataQueryOption.cs
TruncatedCollection truncatedCollection = new TruncatedCollection(queryable, limit, parameterize);
Show raw exception details
TargetInvocationException: Exception has been thrown by the target of an invocation.
System.RuntimeMethodHandle.InvokeMethod(object target, object[] arguments, Signature sig, bool constructor, bool wrapExceptions)
System.Reflection.RuntimeMethodInfo.Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
System.Reflection.MethodBase.Invoke(object obj, object[] parameters)
Microsoft.AspNetCore.OData.Query.ODataQueryOptions.LimitResults(IQueryable queryable, int limit, bool parameterize, out bool resultsLimited) in ODataQueryOption.cs
+
IQueryable results = genericMethod.Invoke(null, args) as IQueryable;
Microsoft.AspNetCore.OData.Query.ODataQueryOptions.ApplyPaging(IQueryable result, ODataQuerySettings querySettings) in ODataQueryOption.cs
+
result = LimitResults(result, pageSize, querySettings.EnableConstantParameterization, out resultsLimited);
Microsoft.AspNetCore.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings) in ODataQueryOption.cs
+
result = ApplyPaging(result, querySettings);
Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.ApplyQuery(IQueryable queryable, ODataQueryOptions queryOptions) in EnableQueryAttribute.cs
+
return queryOptions.ApplyTo(queryable, _querySettings);
Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.ExecuteQuery(object responseValue, IQueryable singleResultCollection, ControllerActionDescriptor actionDescriptor, HttpRequest request) in EnableQueryAttribute.cs
+
queryable = ApplyQuery(queryable, queryOptions);
Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.OnActionExecuted(ActionExecutedContext actionExecutedContext, object responseValue, IQueryable singleResultCollection, ControllerActionDescriptor actionDescriptor, HttpRequest request) in EnableQueryAttribute.cs
+
object queryResult = ExecuteQuery(responseValue, singleResultCollection, actionDescriptor, request);
Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.OnActionExecuted(ActionExecutedContext actionExecutedContext) in EnableQueryAttribute.cs
+
object queryResult = OnActionExecuted(
Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
Microsoft.AspNetCore.OData.Batch.ODataBatchMiddleware.Invoke(HttpContext context) in ODataBatchMiddleware.cs
+
await _next(context).ConfigureAwait(false);
Microsoft.AspNetCore.OData.Query.ODataQueryRequestMiddleware.Invoke(HttpContext context) in ODataQueryRequestMiddleware.cs
+
await _next(context).ConfigureAwait(false);
Microsoft.AspNetCore.OData.Routing.ODataRouteDebugMiddleware.Invoke(HttpContext context) in ODataRouteDebugMiddleware.cs
+
await _next(context).ConfigureAwait(false);
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure in the ODataRoutingSample after replacing EF Core with EF6, using $filter or $select. Start with TruncatedCollectionOfT.cs and ODataQueryOption.cs, then follow the query path through EnableQueryAttribute.cs. Done means these query options execute with EF6 without the reported NotSupportedException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100