我们有一个庞大的数据驱动应用程序,涉及多个系统,因此需要大量映射。由于性能问题,我们将从 AutoMapper 迁移到 Mapster。
到目前为止,Mapster 一切都很好,但是在映射Collections
Mapster 时返回null
value 而不是 empty Collection
。
Automapper 过去默认返回空集合,但我无法弄清楚如何在 Mapster 中执行此操作。
我已尝试执行以下操作,但它不起作用
TypeAdapterConfig.GlobalSettings.ForDestinationType<ICollection>().IgnoreNullValues(true);
TypeAdapterConfig.GlobalSettings.ForType(typeof(ICollection), typeof(ObservableCollection<>))
.IgnoreNullValues(true);
TypeAdapterConfig.GlobalSettings.ForType(typeof(ObservableCollection<>), typeof(ICollection))
.IgnoreNullValues(true);
任何帮助都会很棒