How to tell AutoMapper not to map object graph entirely -


i have series of classes have relations each others. like:

public class patient : entity {     public virtual string firstname { set; get; }     public virtual officebranch originalofficebranch { set; get; } }  public class officebranch : entity {     public virtual string title { set; get; } } 

and dtos:

public class patientdto : basegeneraldto {     public string firstname { set; get; }     public officebranchdto originalofficebranch { set; get; } }  public class officebranchdto : basegeneraldto {     public string title { set; get; } } 

i have used automapper map them each other. i'm using nhibernate persisting. when updating patientdto, automapper causes changes in officebranchdto nhibernate dirty session flush occurs absolutely unwanted.

what want know how can tell automapper not map object graph entirely. mean map patientdto patient not both patientdto , officebranchdto. workaround use add ignore each mapping manually like:

mapper.createmap<patientdto, patient>().formember(m => m.originalofficebranch, => i.ignore()); 

but guess there better solution.

ignoring members don't want map done via ignore(). there's no better solution - how automapper supposed guess want map , don't want map? can't, have explicit.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -