3

プロパティを持つ Article クラスがあります

private IList<Tag> _tags;
public virtual IList<Tag> Tags
{
get{
if(_tags == null)
  _tags = TagService.GetTags(this);
return _tags;
}
}

タグの SET がないため、オートマッパーはビューモデルからビューへのマッピング時にタグを設定しません。何か案は?

4

2 に答える 2

4

UseDestinationValue オプションを使用してみてください。

ForMember(dest => dest.Tags, opt => opt.UseDestinationValue());

トランクの最新の DLL で、AutoMapper は読み取り専用のリスト型メンバーを取得する必要があります。

于 2009-12-03T14:21:49.500 に答える
0

次を使用してプロパティを無視できます。

ForMember(dest => dest.Tags, opt => opt.Ignore());
于 2011-06-01T04:53:11.473 に答える