AutoMapper与IList的-
问题描述:
我有Article类财产AutoMapper与IList的<Item>
private IList<Tag> _tags;
public virtual IList<Tag> Tags
{
get{
if(_tags == null)
_tags = TagService.GetTags(this);
return _tags;
}
}
由于没有SET从视图模型查看映射时automapper不会将标签标签。有任何想法吗?
答
尝试使用UseDestinationValue选项:
ForMember(DEST => dest.Tags,选择=> opt.UseDestinationValue());
在主干上的最新DLL中,AutoMapper应该选择只读列表类型的成员。
答
你可以用忽略然后属性:
ForMember(dest => dest.Tags, opt => opt.Ignore());