c# - AutoMapping custom Generic Types - How? -


O people, I'm using version 1.1.0.188

In my automaker Mapping of units for configured I DTO and vice versa, such as:

  // unit & gt; & Gt; DTo Mapper Creatat & Metatamplate, MetaTemplateDTO & gt; (); Mapper Createmap & lt; Person, person & gt; (); // DTO & gt; & Gt; Unit mapper Createmap & lt; MetaTemplateDTO, MetaTemplate & gt; (); Mapper Createmap & lt; PersonDTO, Person & gt; ();  

When I mapping down (and vice versa) everything works fine

  Mapper. Map & lt; Unit, unit DTO & gt; (Unit); Mapper Map & lt; List & lt; Unit & gt; list & lt; Unit DTO & gt; & Gt; (Institutions);  

Note that the AutoPaper works only with the list above & lt;> to configure anything without me.

I have a generic container (simplified for this example):

  public class container & lt; T & gt; {Public Integer Total Ets {get; Set;} Public ILIST & lt; T & gt; Now, without any extra swapping config, when I do:  
  Mapper Map & lt; Container & lt; Unit & gt;, <{code}  

from the container & lt; EntityDTO & gt; & Gt; (EntityContainer);

I get an auto exception exception:

Missing map mapping or unsupported mapping. Exposure

However, if I add this row to the swap to configure for a specific type, as shown below, then container mapping works.

  Mapper.cctemap , Container & lt; Person & gt; & Gt; ();  

However, it will only work for that person / person type DTO.

Why is that so?

Cool, Cheers

If your normal container class behaves like a list of items, then you may be better off implementing the IEnumerable interface. Then the automaker should be repeated through the object and map it accordingly.


Comments