Skip to content
Steve Wilkes edited this page Sep 17, 2016 · 38 revisions

Overview

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

NuGet version

Basic Use

Object Creation

Create an object from another using:

var customer = Mapper.Map(customerViewModel).ToANew<Customer>();

Deep Cloning

Deep-clone an object using:

var clonedCustomer = Mapper.Clone(customerToBeCloned);

Updating

Update an object's members with values from another using:

Mapper.Map(customerViewModel).Over(customer);

Merging

Update an object's unpopulated members with values from another using:

Mapper.Map(customerViewModel).OnTo(customer);

View a Mapping Execution Plan

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>();
Clone this wiki locally