c# - AutoMapper binding issues -
i having trouble automapper not mapping , viewmodels correctly. primary model has complex property named contact of type contact, have fields on viewmodel named contact[propertyname] example of contactfirst_name.
which seems correct far documentation examples can find say, trying flatten/unflatten model not working. did find "fix" in thread on stack overflow meant added following line
mapper.initialize(cfg => cfg.recognizeprefixes("contact"));
to mappings results in successful 2 way binding. seems wrong me , has thinking misunderstanding way default trappings work?
am i?
viewmodel
public class employeeviewmodel : mvviewmodel { [display(name = "title")] public contacttitleviewmodel contacttitle { get; set; } [display(name = "first name")] public string contactfirst_name { get; set; } public string contactmiddle_names { get; set; } public string contactlast_name { get; set; } public string contactemail_address { get; set; } public string position { get; set; } [tablefields("name")] public list<employeetrainingviewmodel> training { get; set; } }
minimal sql models
public class employee : isqlobject { public contact contact { get; set; } public string position { get; set; } public virtual list<employeetraining> training { get; set; } } public class contact : isqlobject { public contacttitle title { get; set; } public string first_name { get; set; } public string middle_names { get; set; } public string last_name { get; set; } }
Comments
Post a Comment