0

I have two models:

public class LocationMasterModel()
{
    public int LocationId { get; set; }
    public int OtherAddressId { get; set; }
    public OtherAddress OtherAddress { get; set; }
}

public class OtherAddress()
{
    public int OtherAddressId { get; set; }
    public int LocationId { get; set; }
    public LocationMasterModel LocationMaster { get; set; }
}

AutoMapper:

 Mapper.CreateMap<LocationMasterModel, LocationMasterViewModel>();

LocationMasterViewModel is another class that is just used for viewing purposes.

So when I try to get the location from my repository and try to convert from LocationMasterModel to LocationMasterViewModel, I need to stop the reference looping after one level of the hierarchy.

Lauren Rutledge
  • 1,195
  • 5
  • 18
  • 27
  • I am not sure I completely understand the question, but! If you have set up your mappers in the config, just can just choose to not include the extra relations and then the mappers won't map them? –  Mar 24 '18 at 09:10
  • yes . but i required that relations and just want to stop after one hierarchy once model bind .using automapper like here when locationmaster get at that time other address automatically come but inside otheraddress not required location once again . – vyas karnav kumar Mar 24 '18 at 09:24
  • Aha, think I understand now. https://stackoverflow.com/questions/14266108/create-two-automapper-maps-between-the-same-two-object-types This one explains some of it. But basically, you should define in the mapper, what should be mapped and when something should ignore the mapping –  Mar 24 '18 at 11:27

0 Answers0