Beispiel #1
0
        private void FixupProduct(Product previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.ProductReviews.Contains(this))
            {
                previousValue.ProductReviews.Remove(this);
            }

            if (Product != null)
            {
                if (!Product.ProductReviews.Contains(this))
                {
                    Product.ProductReviews.Add(this);
                }

                ProductID = Product.ProductID;
            }
            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Product")
                    && (ChangeTracker.OriginalValues["Product"] == Product))
                {
                    ChangeTracker.OriginalValues.Remove("Product");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Product", previousValue);
                }
                if (Product != null && !Product.ChangeTracker.ChangeTrackingEnabled)
                {
                    Product.StartTracking();
                }
            }
        }
Beispiel #2
0
        private void FixupProduct1(Product previousValue, bool skipKeys = false)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.BillOfMaterials1.Contains(this))
            {
                previousValue.BillOfMaterials1.Remove(this);
            }

            if (Product1 != null)
            {
                if (!Product1.BillOfMaterials1.Contains(this))
                {
                    Product1.BillOfMaterials1.Add(this);
                }

                ProductAssemblyID = Product1.ProductID;
            }
            else if (!skipKeys)
            {
                ProductAssemblyID = null;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Product1")
                    && (ChangeTracker.OriginalValues["Product1"] == Product1))
                {
                    ChangeTracker.OriginalValues.Remove("Product1");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Product1", previousValue);
                }
                if (Product1 != null && !Product1.ChangeTracker.ChangeTrackingEnabled)
                {
                    Product1.StartTracking();
                }
            }
        }