c# - Automapper custom object -


how have configure automapper map this:

class source { guid id; double price; } 

to this:

class destination { guid id; destinationdifference difference; }   class destinationdifference { decimal amount; } 

first: should read faqs on how post question , information should added. (no, i'm not downvoter)

here example how mapping work. please note, i've changed classes bit, because automapper needs properties.

source source = new source(); source.id = guid.newguid(); source.price = 10.0;  mapper.initialize(x => x.createmap<source, destination>()     .formember(a => a.difference,         b => b.mapfrom(s => new destinationdifference() { amount = (decimal)s.price })));  destination destination = mapper.map<source, destination>(source); 

classes:

class source {     public guid id { get; set; }     public double price { get; set; } }  class destination {     public guid id { get; set; }     public destinationdifference difference { get; set; } }  class destinationdifference {     public decimal amount { get; set; } } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -