Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok so I can see a few things you are doing that probably won't help.</p> <p>Firstly this AutoMapper is used to copy Properties in one object to Properties in a diff object. Along the way it might interrogate or manipulate them to get the end result viewmodel in the correct state.</p> <ol> <li>The properties are named 'Get...' which sounds more like a method to me.</li> <li>The setters on your properties are private so AutoSetter won't be able to find them. Change these to minimum internal.</li> <li><p>Use of a parametrized constructor is no longer needed when you use AutoMapper - as you are converting directly from one object to another. The parametised constructor is there mainly to show what is explicitly required by this object.</p> <pre><code>CreateMap&lt;Address, AddressEditViewModel&gt;() .ForMember( x =&gt; x.GetOneAddressByDistrictGuid , o =&gt; o.MapFrom( m =&gt; m."GetOneAddressByDistrictGuid") ) .ForMember( x =&gt; x.GetZipCodes, o =&gt; o.MapFrom( m =&gt; m."GetZipCodes" ) ); </code></pre></li> </ol> <p>What Automapper is really good for is copying from DataObjects into POCO objects, or View Model objects.</p> <pre><code> public class AddressViewModel { public string FullAddress{get;set;} } public class Address { public string Street{get;set;} public string Suburb{get;set;} public string City{get;set;} } CreateMap&lt;Address, AddressViewModel&gt;() .ForMember( x =&gt; x.FullAddress, o =&gt; o.MapFrom( m =&gt; String.Format("{0},{1},{2}"), m.Street, m.Suburb, m.City ) ); Address address = new Address(){ Street = "My Street"; Suburb= "My Suburb"; City= "My City"; }; AddressViewModel addressViewModel = Mapper.Map(address, Address, AddressViewModel); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload