使用 AutoMapper 如何忽略没有可访问 getter 的目的地 属性

With AutoMapper how do I ignore a destination property that does not have an accessible getter

我想忽略目的地上的 属性,但它没有可访问的 getter...

.ForMember(opt=>opt.nameSpecial, src=>src.Ignore())

当我这样做时,我得到“The 属性 'X.nameSpecial' cannot be used in this context because the 'get' accessor is unaccessible

使用以 属性 的名称作为参数的 ForMember 重载。

.ForMember("nameSpecial", src=>src.Ignore())