AutoMapper 8.1.0 Released
source link: https://jimmybogard.com/automapper-8-1-0-released/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
AutoMapper 8.1.0 Released
Today we released AutoMapper 8.1.0:
AutoMapper 8.1 adds a major new feature - attribute-based maps. Attribute maps let you easily declare maps on destination types when you have straightforward scenarios. Instead of:
public class OrderProfile {
public OrderProfile() {
CreateMap<Order, OrderIndexModel>();
CreateMap<Order, OrderEditModel>();
CreateMap<Order, OrderCreateModel>();
}
}
You can declare your type maps directly on the destination types themselves with AutoMapAttribute
:
[AutoMap(typeof(Order))]
public class OrderIndexModel {
// members
}
[AutoMap(typeof(Order))]
public class OrderEditModel {
// members
}
[AutoMap(typeof(Order))]
public class OrderCreateModel {
// members
}
When you perform services.AddAutoMapper
or cfg.AddMaps
for any profile scanning, all attribute maps will get pulled in as well.
For most straightforward member configuration, we included attributes as well.
Enjoy!
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK