Reputation: 11642
I have Article class with property
private IList<Tag> _tags;
public virtual IList<Tag> Tags
{
get{
if(_tags == null)
_tags = TagService.GetTags(this);
return _tags;
}
}
Since there is no SET for Tags automapper will not set tags when mapping from viewmodel to view. Any ideas?
Upvotes: 3
Views: 1035
Reputation: 3697
You can Ignore then property using:
ForMember(dest => dest.Tags, opt => opt.Ignore());
Upvotes: 0
Reputation: 26785
Try using the UseDestinationValue option:
ForMember(dest => dest.Tags, opt => opt.UseDestinationValue());
In the latest DLL on the trunk, AutoMapper should pick up readonly list-type members.
Upvotes: 4