entity framework - Is automapper preventing lazy loading with EF? -
i have been using automapper , seems gets me child entities (even if don't specify them in "include()" clause). there way how make lazy loading possible , child properties if specify them.
thank you,
jakub
after mapping have mapped object without references source entity (which holds database context lazy loading). property values copied destination entity. you not able lazy-loading without source entity.
actually lazy loading works fine - , it's occur during mapping process. specified mappings lazy-loaded properties of entity, , mapper tries values. results in lazy-loading navigation properties have configured mapping. inefficient. disable lazy-loading during mapping can ignore navigation properties in mapping configuration. e.g. if have customer lazy-loaded orders:
mapper.createmap<customer, customerdto>() .formember(s => s.orders, m => m.ignore());
or remove orders
property destination entity customerdto
. if need have customerdto
instance orders inside, best option eager loading of orders, avoid additional queries.
Comments
Post a Comment