Example #1
0
        private void FixupEmployee2(Employee previousValue, bool skipKeys = false)
        {
            if (IsDeserializing)
            {
                return;
            }

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

            if (Employee2 != null)
            {
                if (!Employee2.Employee1.Contains(this))
                {
                    Employee2.Employee1.Add(this);
                }

                ManagerID = Employee2.EmployeeID;
            }
            else if (!skipKeys)
            {
                ManagerID = null;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Employee2")
                    && (ChangeTracker.OriginalValues["Employee2"] == Employee2))
                {
                    ChangeTracker.OriginalValues.Remove("Employee2");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Employee2", previousValue);
                }
                if (Employee2 != null && !Employee2.ChangeTracker.ChangeTrackingEnabled)
                {
                    Employee2.StartTracking();
                }
            }
        }
        private void FixupEmployee(Employee previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

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

            if (Employee != null)
            {
                if (!Employee.EmployeePayHistories.Contains(this))
                {
                    Employee.EmployeePayHistories.Add(this);
                }

                EmployeeID = Employee.EmployeeID;
            }
            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Employee")
                    && (ChangeTracker.OriginalValues["Employee"] == Employee))
                {
                    ChangeTracker.OriginalValues.Remove("Employee");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Employee", previousValue);
                }
                if (Employee != null && !Employee.ChangeTracker.ChangeTrackingEnabled)
                {
                    Employee.StartTracking();
                }
            }
        }
Example #3
0
        private void FixupEmployee(Employee previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && ReferenceEquals(previousValue.SalesPerson, this))
            {
                previousValue.SalesPerson = null;
            }

            if (Employee != null)
            {
                Employee.SalesPerson = this;
                SalesPersonID = Employee.EmployeeID;
            }

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