Closed Robelind closed 2 years ago
.Net 5, AspNetCore.OData 8.0.2, AutoMapper.AspNetCore.OData.EFCore 2.2.1
Request http://localhost:56168/Lifts
Controller [HttpGet("Lifts")] public async Task<IQueryable> Lifts(ODataQueryOptions options) { return await _dbContext.Lifts.GetQueryAsync(_mapper, options, null); }
Exception System.InvalidCastException: Unable to cast object of type 'System.Linq.Expressions.FullConditionalExpression' to type 'System.Linq.Expressions.NewExpression'. at AutoMapper.QueryableExtensions.ExpressionBuilder.<>cDisplayClass10_0.gCreateDestination|3() at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary2 typePairCount, TypeMap typeMap, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps, TypeMap& typeMap) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request, Expression instanceParameter, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.Impl.MappedTypeExpressionBinder.BindMappedTypeExpression(IConfigurationProvider configuration, PropertyMap propertyMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.Impl.MappedTypeExpressionBinder.Build(IConfigurationProvider configuration, PropertyMap propertyMap, TypeMap propertyTypeMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary`2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.<>cDisplayClass10_0.gCreateMemberBinding|4(PropertyExpression propertyExpression, <>cDisplayClass10_1& ) at AutoMapper.QueryableExtensions.ExpressionBuilder.<>c__DisplayClass10_0.gCreateMemberBindings|1() at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary2 typePairCount, TypeMap typeMap, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps, TypeMap& typeMap) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.Impl.EnumerableExpressionBinder.BindEnumerableExpression(IConfigurationProvider configuration, PropertyMap propertyMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.Impl.EnumerableExpressionBinder.Build(IConfigurationProvider configuration, PropertyMap propertyMap, TypeMap propertyTypeMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.<>c__DisplayClass10_0.<CreateMapExpressionCore>g__CreateMemberBinding|4(PropertyExpression propertyExpression, <>c__DisplayClass10_1& ) at AutoMapper.QueryableExtensions.ExpressionBuilder.<>c__DisplayClass10_0.<CreateMapExpressionCore>g__CreateMemberBindings|1() at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary2 typePairCount, TypeMap typeMap, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps, TypeMap& typeMap) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request) at AutoMapper.Internal.LockingConcurrentDictionary2.<>c__DisplayClass2_1.<.ctor>b__1() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.CreateValue() at AutoMapper.Internal.LockingConcurrentDictionary2.GetOrAdd(TKey key) at AutoMapper.QueryableExtensions.ExpressionBuilder.GetMapExpression(Type sourceType, Type destinationType, Object parameters, MemberInfo[] membersToExpand) at AutoMapper.QueryableExtensions.ProjectionExpression.ToCore(Type destinationType, Object parameters, IEnumerable1 memberPathsToExpand) at AutoMapper.QueryableExtensions.ProjectionExpression.ToCore[TResult](Object parameters, IEnumerable1 memberPathsToExpand) at AutoMapper.QueryableExtensions.ProjectionExpression.To[TResult](Object parameters, Expression1[] membersToExpand) at AutoMapper.QueryableExtensions.Extensions.ProjectTo[TDestination](IQueryable source, IConfigurationProvider configuration, Object parameters, Expression1[] membersToExpand) at AutoMapper.Mapper.ProjectTo[TDestination](IQueryable source, Object parameters, Expression1[] membersToExpand) at AutoMapper.AspNet.OData.QueryableExtensions.GetQuery[TModel,TData](IQueryable1 query, IMapper mapper, Expression1 filter, Expression1 queryFunc, IEnumerable1 includeProperties, ProjectionSettings projectionSettings) at AutoMapper.AspNet.OData.QueryableExtensions.GetQueryable[TModel,TData](IQueryable1 query, IMapper mapper, ODataQueryOptions1 options, QuerySettings querySettings, Expression1 filter) at AutoMapper.AspNet.OData.QueryableExtensions.GetQueryAsync[TModel,TData](IQueryable1 query, IMapper mapper, ODataQueryOptions1 options, QuerySettings querySettings) at CompactStore.CommonAPI.Controllers.LiftsController.Lifts(ODataQueryOptions1 options) in C:\Users\rli\source\repos\CompactStoreNG\CompactStore\CommonAPI\Controllers\LiftsController.cs:line 44 at lambda_method5(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gAwaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2 typePairCount, TypeMap typeMap, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary
2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.Impl.MappedTypeExpressionBinder.BindMappedTypeExpression(IConfigurationProvider configuration, PropertyMap propertyMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary
2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.Impl.EnumerableExpressionBinder.BindEnumerableExpression(IConfigurationProvider configuration, PropertyMap propertyMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary
2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.<>c__DisplayClass10_0.<CreateMapExpressionCore>g__CreateMemberBinding|4(PropertyExpression propertyExpression, <>c__DisplayClass10_1& ) at AutoMapper.QueryableExtensions.ExpressionBuilder.<>c__DisplayClass10_0.<CreateMapExpressionCore>g__CreateMemberBindings|1() at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary
2 typePairCount, LetPropertyMaps letPropertyMaps, TypeMap& typeMap) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request, IDictionary
2.<>c__DisplayClass2_1.<.ctor>b__1() at System.Lazy
1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy
2.GetOrAdd(TKey key) at AutoMapper.QueryableExtensions.ExpressionBuilder.GetMapExpression(Type sourceType, Type destinationType, Object parameters, MemberInfo[] membersToExpand) at AutoMapper.QueryableExtensions.ProjectionExpression.ToCore(Type destinationType, Object parameters, IEnumerable
1 memberPathsToExpand) at AutoMapper.QueryableExtensions.ProjectionExpression.To[TResult](Object parameters, Expression
1[] membersToExpand) at AutoMapper.Mapper.ProjectTo[TDestination](IQueryable source, Object parameters, Expression
1 query, IMapper mapper, Expression
1 queryFunc, IEnumerable
1 query, IMapper mapper, ODataQueryOptions
1 filter) at AutoMapper.AspNet.OData.QueryableExtensions.GetQueryAsync[TModel,TData](IQueryable
1 options, QuerySettings querySettings) at CompactStore.CommonAPI.Controllers.LiftsController.Lifts(ODataQueryOptions
Better to narrow this down if you need help.
.Net 5, AspNetCore.OData 8.0.2, AutoMapper.AspNetCore.OData.EFCore 2.2.1
Request http://localhost:56168/Lifts
Controller [HttpGet("Lifts")] public async Task<IQueryable> Lifts(ODataQueryOptions options)
{
return await _dbContext.Lifts.GetQueryAsync(_mapper, options, null);
}
Exception System.InvalidCastException: Unable to cast object of type 'System.Linq.Expressions.FullConditionalExpression' to type 'System.Linq.Expressions.NewExpression'. at AutoMapper.QueryableExtensions.ExpressionBuilder.<>cDisplayClass10_0.gCreateDestination|3()
at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionaryg CreateMemberBinding|4(PropertyExpression propertyExpression, <>cDisplayClass10_1& )
at AutoMapper.QueryableExtensions.ExpressionBuilder.<>c__DisplayClass10_0.g CreateMemberBindings|1()
at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionarygAwaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
2 typePairCount, TypeMap typeMap, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary
2 typePairCount, LetPropertyMaps letPropertyMaps, TypeMap& typeMap) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request, Expression instanceParameter, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.Impl.MappedTypeExpressionBinder.BindMappedTypeExpression(IConfigurationProvider configuration, PropertyMap propertyMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary
2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.Impl.MappedTypeExpressionBinder.Build(IConfigurationProvider configuration, PropertyMap propertyMap, TypeMap propertyTypeMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary`2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.<>cDisplayClass10_0.2 typePairCount, TypeMap typeMap, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary
2 typePairCount, LetPropertyMaps letPropertyMaps, TypeMap& typeMap) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.Impl.EnumerableExpressionBinder.BindEnumerableExpression(IConfigurationProvider configuration, PropertyMap propertyMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary
2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.Impl.EnumerableExpressionBinder.Build(IConfigurationProvider configuration, PropertyMap propertyMap, TypeMap propertyTypeMap, ExpressionRequest request, ExpressionResolutionResult result, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.<>c__DisplayClass10_0.<CreateMapExpressionCore>g__CreateMemberBinding|4(PropertyExpression propertyExpression, <>c__DisplayClass10_1& ) at AutoMapper.QueryableExtensions.ExpressionBuilder.<>c__DisplayClass10_0.<CreateMapExpressionCore>g__CreateMemberBindings|1() at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary
2 typePairCount, TypeMap typeMap, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpressionCore(ExpressionRequest request, Expression instanceParameter, IDictionary2 typePairCount, LetPropertyMaps letPropertyMaps, TypeMap& typeMap) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request, IDictionary
2 typePairCount, LetPropertyMaps letPropertyMaps) at AutoMapper.QueryableExtensions.ExpressionBuilder.CreateMapExpression(ExpressionRequest request) at AutoMapper.Internal.LockingConcurrentDictionary2.<>c__DisplayClass2_1.<.ctor>b__1() at System.Lazy
1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy
1.CreateValue() at AutoMapper.Internal.LockingConcurrentDictionary2.GetOrAdd(TKey key) at AutoMapper.QueryableExtensions.ExpressionBuilder.GetMapExpression(Type sourceType, Type destinationType, Object parameters, MemberInfo[] membersToExpand) at AutoMapper.QueryableExtensions.ProjectionExpression.ToCore(Type destinationType, Object parameters, IEnumerable
1 memberPathsToExpand) at AutoMapper.QueryableExtensions.ProjectionExpression.ToCore[TResult](Object parameters, IEnumerable1 memberPathsToExpand) at AutoMapper.QueryableExtensions.ProjectionExpression.To[TResult](Object parameters, Expression
1[] membersToExpand) at AutoMapper.QueryableExtensions.Extensions.ProjectTo[TDestination](IQueryable source, IConfigurationProvider configuration, Object parameters, Expression1[] membersToExpand) at AutoMapper.Mapper.ProjectTo[TDestination](IQueryable source, Object parameters, Expression
1[] membersToExpand) at AutoMapper.AspNet.OData.QueryableExtensions.GetQuery[TModel,TData](IQueryable1 query, IMapper mapper, Expression
1 filter, Expression1 queryFunc, IEnumerable
1 includeProperties, ProjectionSettings projectionSettings) at AutoMapper.AspNet.OData.QueryableExtensions.GetQueryable[TModel,TData](IQueryable1 query, IMapper mapper, ODataQueryOptions
1 options, QuerySettings querySettings, Expression1 filter) at AutoMapper.AspNet.OData.QueryableExtensions.GetQueryAsync[TModel,TData](IQueryable
1 query, IMapper mapper, ODataQueryOptions1 options, QuerySettings querySettings) at CompactStore.CommonAPI.Controllers.LiftsController.Lifts(ODataQueryOptions
1 options) in C:\Users\rli\source\repos\CompactStoreNG\CompactStore\CommonAPI\Controllers\LiftsController.cs:line 44 at lambda_method5(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.