c# - How to create a map from model to Entity, and Entity to model, with AutoMapper? -
i have model
class account { public string name {get; set;} public string emailaddress1 {get;set;} }
is possible configure automapper somehow loop through each property on class , map correct entity value.
i able make converter reflection myself:
public entity converttoentity() { var propertydict = typeof(account).getproperties().select(x => new keyvaluepair<string, object>(x.name, x.getvalue(typeof(account)))); entity entity = new entity(); foreach (var prop in propertydict) t[prop.key] = prop.value; return entity; }
but how can achieve same kind of functionality automapper's createmap?
Comments
Post a Comment