You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Backstory: as a part of an upgrade we moved from using DateTime to DateTimeOffset for our users. Idea is to keep EF definitions the same (everything stays System.DateTime) but configure AutoMapper such that we convert it to System.DateTimeOffset.
So in AutoMapperConfiguration.Configure() I've defined:
I could do this with an expression-based version (it must be an expression to be passed down to EF, and effectively be converted to SQL and/or done server-side). Would that work?
Backstory: as a part of an upgrade we moved from using DateTime to DateTimeOffset for our users. Idea is to keep EF definitions the same (everything stays System.DateTime) but configure AutoMapper such that we convert it to System.DateTimeOffset.
So in AutoMapperConfiguration.Configure() I've defined:
Basically all possible scenarios where a conversion might be needed.
For example, I've defined DateTimeConverter() like so:
Now the conversions works great when I try to do (MyEntity being the EF entity):
return Mapper.Map<MyEntity, MyEntity2>(queryResult.Single())
But when I do this:
IQueryable<MyEntity2> entityQueryable = db.MyEntity.Project().To<MyEntity2>();
I get the following exception: AutoMapperException
Unable to create a map expression from System.DateTime to System.DateTimeOffset
The text was updated successfully, but these errors were encountered: