如何使用Mapster将视图模型映射到富域模型

时间:2020-07-30 02:49:02

标签: c# domain-driven-design asp.net-mvc-viewmodel mapster rich-domain-model

好吧

我有一个带有私人集合成员的实体:

public class Tool : Entity<int> // this Entity has SetId() method to change the id of an object
{
    public Tool(string name, string description)
    {
      Name = name;
      Description = description;
      MakeValidation(this, new ToolValidator());
    }

    public string Name { get; private set; }
    public string Description { get; private set; }

    public void UpdateName(string name)
    {
      Name = name;
      MakeValidation(this, new ToolValidator());
    }

    public void UpdateDescription(string description)
    {
      Description = description;
      MakeValidation(this, new ToolValidator());
    }
}

我有一个视图模型:

  public class ToolViewModel : ViewModel<int> // this ViewModel has the Id property
  {
    public string Name { get; set; }
    public string Description { get; set; }
    public bool Status { get; set; }
  }

我曾尝试使用ConstructUsing和MapWith,但没有成功。我该怎么办?

0 个答案:

没有答案
相关问题