public void Insert(Domain.Models.ProductAggregate.Product entity) { Models.Product product = entity.ToRepositoryModel(); // avoids inserting children elements var productClone = product.DeepClone(); productClone.ProductParts = null; this.InsertProduct(productClone); IEnumerable <Models.Material> materials = product.ProductParts .Select(p => p.ProductPartMaterials.Select(m => m.Material)) .SelectMany(m => m); this.InsertMaterials(materials); this.InsertProductParts(product); }