asp.net - automapper, Can I auto assign Guid to UserId of my UserDTO? -
i want assign guid userid of userdto if userid null. possible in createmap or creating formatter?. using automapper attribute on actions in controller.
protected override void configure() { mapper.createmap<user, userdto>() .formember(d => d.fullname, o => o.mapfrom(s => s.firstname + " " + s.lastname)); }
why not just:
public class userdto { string _userid; public string userid { { if (_userid == null) _userid = new guid().tostring(); return _userid; } set { _userid = value; } } }
Comments
Post a Comment