代码之家  ›  专栏  ›  技术社区  ›  Andrej Kaurin

带ilist的automapper<item>

  •  3
  • Andrej Kaurin  · 技术社区  · 15 年前

    我有带财产的物品课

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

    因为没有设置标签,所以在从视图模型映射到视图时,automapper不会设置标签。有什么想法吗?

    2 回复  |  直到 13 年前
        1
  •  4
  •   Jimmy Bogard    15 年前

    尝试使用useDestinationValue选项:

    表单成员(dest=>dest.tags,opt=>opt.useDestinationValue());

    在主干上最新的dll中,automapper应该选择只读列表类型成员。

        2
  •  0
  •   BitKFu    13 年前

    可以使用以下命令忽略Then属性:

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