0

我通常需要为 Mapster 做的唯一配置如下:-

class Child
{
  public int ChildId
  public string Name
  public Parent Parent
}

class Parent
{
  public int ParentId
  public string Name
}

class ChildDest
{
  public int ChildId
  public string Name
  public int ParentId
}

TypeAdapterConfig<Child, ChildDest>
  .NewConfig()
  .Map(dest => dest.ParentId, src => src.Parent.ParentId)

如果我的父 id 字段刚刚被称为“Id”,我认为 mapster 只会使用默认配置将其展平,并且我不需要 TypeAdapterConfig。如何更改全局配置规则以使 Mapster 自动将 Parent.ParentSomething 展平为 ParentSomething?

4

0 回答 0