Missing support for ProjectTo
See original GitHub issueThe following code:
var res = await mContext.Entities
.ProjectTo<Model>(mMapper.ConfigurationProvider)
.ToListAsync();
produces an error when executed with mocked db:
at System.Linq.Expressions.Expression.ValidateLambdaArgs(Type delegateType, Expression& body, ReadOnlyCollection`1 parameters, String paramName)
at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, String name, Boolean tailCall, IEnumerable`1 parameters)
at System.Linq.Expressions.Expression.Lambda[TDelegate](Expression body, IEnumerable`1 parameters)
at EntityFrameworkCoreMock.DbAsyncEnumerable`1.CompileExpression[T](Expression expression)
at EntityFrameworkCoreMock.DbAsyncEnumerable`1..ctor(Expression expression)
at EntityFrameworkCoreMock.DbAsyncQueryProvider`1.CreateQuery(Expression expression)
at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
at AutoMapper.QueryableExtensions.ProjectionExpression.To[TResult](Object parameters, Expression`1[] membersToExpand) in C:\projects\automapper\src\AutoMapper\QueryableExtensions\ProjectionExpression.cs:line 62
at AutoMapper.QueryableExtensions.Extensions.ProjectTo[TDestination](IQueryable source, IConfigurationProvider configuration, Expression`1[] membersToExpand) in C:\projects\automapper\src\AutoMapper\QueryableExtensions\Extensions.cs:line 76
at MyCode.IRepository.GetAll()
at MyTest.RepositoryShould.Add()
Result Message:
Test method MyTest.RepositoryShould.Add threw exception:
System.ArgumentException: Expression of type 'System.Linq.IQueryable`1[Model]' cannot be used for return type 'System.Collections.Generic.IEnumerable`1[Entity]'
ProjectTo
is AutoMapper
extension.
Preprequisites: Entity
class, Model
class, and a map from Entity
to Model
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11
Top Results From Across the Web
ProjectTo does not recognize parameterless constructor
NotSupportedException: Only parameterless constructors and initializers are supported in LINQ to Entities. Why? My class does have a ...
Read more >Casting issue with AutoMapper's ProjectTo method : r/csharp
Hi, I need to use AutoMapper to map db entities (User) to domain entities (UserDto). Instead of Map I just wanted to use...
Read more >Queryable Extensions
ProjectTo must be the last call in the chain. ORMs work with entities, not DTOs. So apply any filtering and sorting on entities...
Read more >AutoMapper LINQ Support Deep Dive
My favorite feature of AutoMapper is its LINQ support. If you're using AutoMapper, and not using its queryable extensions, you're missing ...
Read more >Missing Prefabs when Moving Project to Official Unity ...
Hi! When I transfer my project (2018.2.0b9) to any official version of Unity, my scene is missing almost all of the game objects....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, will do after Easter.
If so, please try version 1.0.0.25 or higher, where I’ve downgraded the EF Core dependency.