After matching, you will have a mapped object without any reference to the original object (which contains the database context for lazy loading). Only property values ββare copied to the target. Thus, you cannot perform lazy loading without the original entity.
In fact, lazy loading works just fine for you - and this happens during the mapping process. You specified mappings for the lazy properties of your object, and mapper is trying to get these values. This results in lazy loading of all the navigation properties that you configured for mapping. It is very inefficient. To disable lazy loading during matching, you can ignore the navigation properties in the mapping configuration. For instance. if you have a customer with lazy orders:
Mapper.CreateMap<Customer, CustomerDto>() .ForMember(s => s.Orders, m => m.Ignore());
Or remove the Orders property from your CustomerDto target. If you need to have a CustomerDto instance with orders inside, then the best option is to load orders in order to avoid additional requests.
source share