プロパティを持つ Article クラスがあります
private IList<Tag> _tags;
public virtual IList<Tag> Tags
{
get{
if(_tags == null)
_tags = TagService.GetTags(this);
return _tags;
}
}
タグの SET がないため、オートマッパーはビューモデルからビューへのマッピング時にタグを設定しません。何か案は?
プロパティを持つ Article クラスがあります
private IList<Tag> _tags;
public virtual IList<Tag> Tags
{
get{
if(_tags == null)
_tags = TagService.GetTags(this);
return _tags;
}
}
タグの SET がないため、オートマッパーはビューモデルからビューへのマッピング時にタグを設定しません。何か案は?
UseDestinationValue オプションを使用してみてください。
ForMember(dest => dest.Tags, opt => opt.UseDestinationValue());
トランクの最新の DLL で、AutoMapper は読み取り専用のリスト型メンバーを取得する必要があります。
次を使用してプロパティを無視できます。
ForMember(dest => dest.Tags, opt => opt.Ignore());