AutoMapper排除字段 [英] AutoMapper Exclude Fields
本文介绍了AutoMapper排除字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将一个对象映射到另一个对象,但是该对象非常复杂.在开发过程中,我希望能够排除一堆字段并一个接一个地访问它们,或者能够指定仅映射我想要的字段并在每次测试成功时增加它.
I'm trying to map one object to another but the object is quite complex. During development, I'd like the ability to either exclude a bunch of fields and get to them one by one or be able to specify to map only fields I want and increase that as each test succeeds.
所以:
class
string field1
string field2
string field3
现在,我想映射field1
,进行测试,修复,然后移动到field2
然后是field3
.
Now I'd like to map field1
, test, fix and then move onto field2
then field3
.
这可能吗?
推荐答案
.ForMember(dto => dto.field1, opt => opt.Ignore());
这篇关于AutoMapper排除字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文