c# - Mapping not found -


i've been struggling automapper , nested objects. following error:

missing type map configuration or unsupported mapping. adminschema -> schema 

but doesn't seem right me, because have following mapping configured:

mapper.createmap<schema, adminschema>().reversemap(); 

it should mapping following models:

public class adminschema {     [required]     [display(name = "opeenvolgende weken")]     public int consecutiveweeks { get; set; }      public list<adminworkday> workdays { get; set; }      public bool delete { get; set; } }  public class adminworkday {     public int dayofweeknumber { get; set; }     public string starttime { get; set; }     public string endtime { get; set; }     public timespan breaktime { get; set; }     public bool delete { get; set; } } 

to

public class schema {     public int id { get; set; }      public int consecutiveweeks { get; set; }     public list<workday> workdays { get; set; }  }  public class workday {     public int id { get; set; }      public int dayofweeknumber { get; set; }     public datetime starttime { get; set; }     public datetime endtime { get;set; }     public timespan breaktime { get; set; } } 

for string datetime mapping, have following code:

mapper.createmap<string, datetime>().convertusing<stringtodatetimeconverter>();  public class stringtodatetimeconverter : itypeconverter<string, datetime> {     public datetime convert(resolutioncontext context)     {         var sourcedt = context.sourcevalue;         datetime targetdt;          if (sourcedt == null)         {             return default(datetime);         }         return datetime.tryparse(sourcedt.tostring(), out targetdt) ? targetdt : default(datetime);     } } 

and here implementation of mapping:

var workperiod = new workperiod {             schemas = mapper.map<list<adminschema>, list<schema>>(workperiodvm.schemas)         }; 

if might have idea why doesn't find mapping, please let me know. appreciated. other mappings work thec onfiguration of automapper in general correct.

obviously types of workdays in tsource , tdestination aren't equal, while have set tsource , tdestination types equal in automapper nuget package. example change tsource , tdestination types adminworkday workdays properties , see works properly.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -