I'm using AutoMapper and I want to add Convention for specific property name, such as ABC_DEF -> ABCDEF. I know how to add convention for all properties names. How to add only for specific property? Thanks.
For all property names:
AddMemberConfiguration().AddName<ReplaceName>(_ => _.AddReplace("Ä", "A").AddReplace("í", "i"));
EDIT:
For example class with properties:
public class Test
{
public int ABC_PROP1 { get; set; }
public int ABC_PROP2 { get; set; }
public int ABC_PROP3 { get; set; }
public int CDE_PROP4 { get; set; }
public int EFG_PROP5 { get; set; }
}
And I want to replace "_" only in properties starts with ABC. But without MapForm. Is it possible use convention?
You can use MapFrom for a specific property name. It lets you redirect from one property to another.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.