-
Notifications
You must be signed in to change notification settings - Fork 54
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I have a mapping like this :
CreateMap<Order, OrderDTO>()
.ForMember(d => d.Lines, o => o.MapFrom(s => s.Lines.Where(b => b.Validated)));The Lines property in Order class is of type IList<OrderLine> while the Lines property in OrderDTO class if of type IEnumerable<OrderLineDTO>.
In this case, when I try to expand the Lines property with OData, I get this exception :
System.InvalidOperationException: No generic method 'Include' on type 'Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.
at System.Linq.Expressions.Expression.FindMethod(Type type, String methodName, Type[] typeArgs, Expression[] args, BindingFlags flags)
at System.Linq.Expressions.Expression.Call(Type type, String methodName, Type[] typeArguments, Expression[] arguments)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at AutoMapper.Extensions.ExpressionMapping.MapperExtensions.<MapExpression>g__MapBody|8_1[TDestDelegate](Dictionary`2 typeMappings, XpressionMapperVisitor visitor, <>c__DisplayClass8_0`1& )
at AutoMapper.Extensions.ExpressionMapping.MapperExtensions.MapExpression[TDestDelegate](IConfigurationProvider configurationProvider, LambdaExpression expression, Type typeSourceFunc, Type typeDestFunc, Func`3 getVisitor, Func`2 shouldConvertMappedBodyToDestType)
at AutoMapper.Extensions.ExpressionMapping.MapperExtensions.MapExpression[TDestDelegate](IMapper mapper, LambdaExpression expression, Func`3 getVisitor, Func`2 shouldConvertMappedBodyToDestType)
at AutoMapper.Extensions.ExpressionMapping.MapperExtensions.MapExpressionAsInclude[TDestDelegate](IMapper mapper, LambdaExpression expression)
at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at AutoMapper.AspNet.OData.QueryableExtensions.GetDataQuery[TModel,TData](IQueryable`1 query, IMapper mapper, Expression`1 filter, Expression`1 queryFunc, ICollection`1 includeProperties)
at AutoMapper.AspNet.OData.QueryableExtensions.GetAsync[TModel,TData](IQueryable`1 query, IMapper mapper, Expression`1 filter, Expression`1 queryFunc, ICollection`1 includeProperties, AsyncSettings asyncSettings)
at AutoMapper.AspNet.OData.QueryableExtensions.GetAsync[TModel,TData](IQueryable`1 query, IMapper mapper, ODataQueryOptions`1 options, QuerySettings querySettings)
at WebApplication1.Controllers.TestController.GetAsync(ODataQueryOptions`1 options) in D:\Dev\Perso\AutoMapperTest\AutoMapperTest\WebApplication1\Controllers\TestController.cs:line 24
I did a sample project here : https://github.com/kakone/AutoMapperTest. When you call /Test?$expand=Lines, the exception appears.
I'm going to try to do a PR to fix this kind of problem.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working