public void UpdateGraph(ProductLine productLine) { if (productLine == null) { throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null."); } productLine.ApplyKeys(); Update(productLine); MergeAll(productLine.Products); }
public int Create(ProductLine productLine) { if (productLine == null) { throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null."); } var key = Insert <ProductLine, int>(productLine); productLine.ApplyKeys(); InsertAll(productLine.Products); return(key); }
public void UpdateGraphWithDeletes(ProductLine productLine, IList <int> productKeysToRemove) { if (productLine == null) { throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null."); } productLine.ApplyKeys(); Update(productLine); if (productKeysToRemove?.Any() == true) { Delete <Product>(e => productKeysToRemove.Contains(e.ProductKey)); } if (productLine.Products?.Any() == true) { MergeAll <Product>(productLine.Products); } }
public void UpdateGraphWithChildDeletes(ProductLine productLine) { if (productLine == null) { throw new ArgumentNullException(nameof(productLine), $"{nameof(productLine)} is null."); } productLine.ApplyKeys(); var products = Query <Product>(p => p.ProductLineKey == productLine.ProductLineKey); var originalProductKeys = products .Select(p => p.ProductKey); var currentProductKeys = productLine .Products .Select(e => e.ProductKey); var productKeysToRemove = originalProductKeys .Except(currentProductKeys) .AsList(); UpdateGraphWithDeletes(productLine, productKeysToRemove); }