Skip to content

Commit ef7f102

Browse files
Merge pull request #234 from dacky179/fix/SaveInstance
Filter Parent-Property from ProductInstance.
2 parents 0f41b89 + fbd208b commit ef7f102

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/Moryx.Products.Management/Facades/ProductManagementFacade.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ public ProductInstance GetInstance(IIdentity identity)
226226
.GetInstances<IIdentifiableObject>(i => identity.Equals(i.Identity));
227227
if (instances.Count > 1)
228228
{
229-
Logger.Log(LogLevel.Error, "ProductManagement contains more than one {0} with the identity {1}.", nameof(ProductInstance), identity);
230-
throw new InvalidOperationException();
229+
Logger.Log(LogLevel.Error, "ProductManagement contains more than one {0} with identity {1}.", nameof(ProductInstance), identity);
230+
throw new InvalidOperationException($"More than one instance found!");
231231
}
232232

233233
return (ProductInstance) instances.SingleOrDefault(); ;

src/Moryx.Products.Management/Implementation/Storage/ProductStorage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,9 @@ private ProductInstanceEntity SaveInstance(IUnitOfWork uow, ProductInstance prod
10221022
strategy.SaveInstance(productInstance, archived);
10231023

10241024
// Save its parts if they have a dedicated archive
1025-
var partsContainer = ReflectionTool.GetReferences<ProductInstance>(productInstance);
1025+
var partsContainer = ReflectionTool.GetReferences<ProductInstance>(productInstance)
1026+
.Where(p => p.Key.Name != nameof(ProductInstance.Parent));
1027+
10261028
foreach (var partGroup in partsContainer)
10271029
{
10281030
foreach (var part in partGroup)

0 commit comments

Comments
 (0)