I keep getting Exceptions when trying to resolve entities with AutoMapper in viewmodels, and I can't figure out why.
Following code
Mapper.CreateMap<Article, ArticleViewModel>()
.ForMember(a => a.CreatedDate, a => a.ResolveUsing<DateResolver>())
.ForMember(a => a.Content, a => a.ResolveUsing<ContentResolver>().ConstructedBy(() =>
new ContentResolver(articleParserFactory)));
var test = this.context.Articles
.Project()
.To<ArticleViewModel>()
.ToArray();
always throws an exception with the message "Unable to resolve this for Queryable Expression". How can i fix this?
EDIT: this does not seem to be a problem for .Project (). To (), if I remove ValueResolvers in the above code, AutoMapper does its thing. Strange, if I stick only with DateResolver, AutoMapper never enters the ResolveCore method, but instead throws the same exception.
source
share