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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -