-
Notifications
You must be signed in to change notification settings - Fork 27
Home
AgileMapper is a zero-configuration, highly-configurable, portable object-object mapper with viewable execution plans. It performs deep clones, id-aware updates and merges, and can be used via a static or instance API.
Mapping functions are created and cached the first time two types are mapped - no up-front configuration is necessary. You can cache up-front if you want to, though.
Available via NuGet and licensed with the MIT licence, you can install it via the package manager console:
PM> Install-Package AgileObjects.AgileMapper
Create an object from another using:
var customer = Mapper.Map(customerViewModel).ToANew<Customer>();
Deep-clone an object using:
var clonedCustomer = Mapper.Clone(customerToBeCloned);
Update an object's members with values from another using:
Mapper.Map(customerViewModel).Over(customer);
Update an object's unpopulated members with values from another using:
Mapper.Map(customerViewModel).OnTo(customer);
View the execution plan to see how two object types will be mapped; this also caches the plan, so you can use it to choose when to incur that cost. Use:
// For object creation:
var mappingPlan = Mapper.GetPlanFor<Customer>().ToANew<CustomerViewModel>();
// For updates:
var mappingPlan = Mapper.GetPlanFor<Customer>().Over<CustomerViewModel>();
// For merges:
var mappingPlan = Mapper.GetPlanFor<Customer>().OnTo<CustomerViewModel>();