using System.Collections.Generic;
using AgileObjects.AgileMapper;
public static void Main()
.FromDictionariesWithValueType<ProductDto>()
.Map(ctx => ctx.Source.Values)
var source = new Dictionary<string, ProductDto>
{ "1", new ProductDto { Id = 1, Name = "Product 1", Price = 11.99 } },
{ "2", new ProductDto { Id = 2, Name = "Product 2", Price = 12.99 } }
var target = new List<Product>
new Product { Id = 2, Name = "Prod 2" },
new Product { Id = 3, Name = "Prod 3", Price = 3.99 }
var preUpdateProduct2 = target[0];
Mapper.Map(source).Over(target);
Console.WriteLine("Overwrite mapping, so Product 1 is added, Product 2 is updated and Product 3 is removed:");
foreach (var product in target.OrderBy(p => p.Id))
Console.WriteLine("Id = " + product.Id + ", Name = " + product.Name + ", Price = " + product.Price);
Console.WriteLine("Same Product 2 object used?: " + Equals(preUpdateProduct2, target[0]));
public int Id { get; set; }
public string Name { get; set; }
public double Price { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public double Price { get; set; }