ProjectTo gives error but Map works #4241
nealrobben
started this conversation in
NA
Replies: 1 comment 1 reply
-
That's because that operation is not supported: https://docs.automapper.org/en/stable/Queryable-Extensions.html#supported-mapping-options And will never be supported by arbitrary LINQ query providers. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm on version 12.0.0 of automapper and I have some strange behavior.
My application uses EF 7.0.0 to query a LocalDB database and has the following class (simplified):
To experiment with DDD I wanted to start using value objects.
My first step was to change the ID to a value object:
The definition for DepartmentId is the following:
I want to map this entity to a viewmodel which has an integer for the DepartmentId:
My mapping:
profile.CreateMap<Department, DepartmentDetailVM>()
To be able to map the types I created a custom TypeConverter:
The problem I am having is with ProjectTo.
The following query does NOT work:
However, the following DOES work:
I think this is some strange behavior because if I'm doing something wrong in my mapping I would expect both pieces of code to fail.
The error I get with ProjectTo is:
Am I doing something wrong? The fact that the second piece of code works suggests my mapping is OK.
But why doesn't ProjectTo work then?
Can anyone explain to me what is going wrong here?
Any feedback would be much appreciated.
Kind regards,
Neal
Beta Was this translation helpful? Give feedback.
All reactions