2

我们遇到了使用 Mapster 7.2.0将类映射到接口的问题。映射到目标接口

public interface ITarget 
{
  int GetOnlyProperty {get;}
  int GetSetProperty {get;set;}
}

withsource.Adapt<ITarget>()总是导致GetOnlyProperty具有默认值0

但是,如果目标接口具有所有只读属性,例如

public interface IReadonlyTarget 
    {
      int GetOnlyProperty {get;}
      int GetSetProperty {get;}
    }

两者GetOnlyPropertyGetSetProperty从源设置为正确的值。

这是一个错误还是一个功能,如果是一个功能,如何让 Mapster 使用只读和可写目标属性填充目标接口?

4

0 回答 0