c# - Automapper mapping collection of enums into view model collection -


  • automapper 5.3.0 alpha (yet upgrade latest , greatest)

i have dto follows:

public class aoacrudfieldvaluesgdatahealthinput {     public aoacrudfieldvaluesgdatahealthinput()     {        prevhealthassessment = new hashset<healthprevhealthassessmentenum>();     }      public hashset<healthprevhealthassessmentenum> prevhealthassessment { get; set; } } 

and ef poco of:

[table("health", schema = "gdata")] public class gdatahealthtablemodel : auditedentity {     public gdatahealthtablemodel()     {         //prevhealthassessment = new hashset<healthprevhealthassessmentenum>();     }      [foreignkey("id")]     public icollection<gdatahealthprevassesmenttablemodel> prevhealthassessment { get; set; } } 

and:

[table("healthprevassesment", schema = "gdata")] public class gdatahealthprevassesmenttablemodel : auditedentity {     public healthprevhealthassessmentenum assessment { get; set; } } 

i need extending map:

createmap<aoacrudfieldvaluesgdatahealthinput, gdatahealthtablemodel>(); 

such aoacrudfieldvaluesgdatahealthinput.prevhealthassessment ends in gdatahealthtablemodel.prevhealthassessment. error createmap() not detailed enough - naturally.

is possible? or mapper ignore field , hand?

note: both ef poco's have omitted id field auto increment sake of brevity.

define additional map healthprevhealthassessmentenum -> gdatahealthprevassesmenttablemodel:

createmap<aoacrudfieldvaluesgdatahealthinput, gdatahealthtablemodel>()     .formember(dest => dest.prevhealthassessment, o => o.mapfrom(src => src.prevhealthassessment));  createmap<healthprevhealthassessmentenum, gdatahealthprevassesmenttablemodel>()     .formember(dest => dest.id, o => o.ignore()) // auto id     .formember(dest => dest.assessment , o => o.mapfrom(src => src)); 

not sure of automapper can convert icollection hashset out of box, think can.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -