entity framework - Mapping one DTO to multiple entities -


i have db model following. here describe entities have in ef model:

   public class person    {       public int id { get; set; }       public int addressid { get; set; }       public int roleid { get; set; }       public string name { get; set; }       public string email { get; set; }    }     public class address    {       public int id { get; set; }       public int countryid { get;set; }       public string city { get; set; }    }     public class role    {       public int id { get; set; }       public string name { get; set; }    }     public class country    {       public int id { get; set; }       public string name { get; set; }    } 

on front end have management interface allowing edit user info. so, in each of grid lines show following dto object:

   public class systemuser    {       public string username { get; set; }       public string email { get; set; }       public string city { get; set; }       public string country { get; set; }       public string role { get; set; }    } 

the main question have - best way of mapping entities after edit performed , dto automapper or else?

or doing stupid here?

edit: there challenge have: minimize round trips db.

i find automapper great choice creating view models etc. when saving find using service class method such save(systemuser user) best because have room control on validation , other things must done. mapping code creating entities need save hand done, because there lot more factors involved in save in read. therefore automapper isn't such choice here. write service class repositories various entities in it's constructor. more allow unit testing haven't mentioned, design anyway. if sort of thing need think on right track.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -