public Stock Convert(IStockEntity stockEntity, IStockConverter.OnObjectCreation onObjectCreation) { Stock stock = domainFactory.CreateStock(stockEntity.Id, stockEntity.ProductId, stockEntity.Amount, stockEntity.Date, repositoryFactory.ProductsRepository.Get(stockEntity.ProductId)); // trigger cache on instantiation to prevent looping. onObjectCreation(stock, stockEntity); return(stock); }