public ChangedProperty[] GetChangedProperties <T> (T values, bool onlyTracked) { var changedProperties = new List <ChangedProperty> (); var oldTrackedValues = GetEntityProperties(this, onlyTracked); var newTrackedValues = GetEntityProperties <T> (values, onlyTracked); // TODO: Maybe wrap class and return error messages ? // if(currentTrackedValues.Count != newTrackedValues.Count) // return ; foreach (var newTrackedValue in newTrackedValues) { var changedValue = oldTrackedValues.FirstOrDefault(x => (x.name == newTrackedValue.name) && (!EqualityHelper.JsonCompare(x.value, newTrackedValue.value))); if (changedValue != null) { changedProperties.Add(new ChangedProperty() { NewValue = newTrackedValue.value, OldValue = changedValue.value, PropertyName = changedValue.name }); } } return(changedProperties.ToArray()); }
public bool EntityPropertiesEqual(object values, bool onlyTracked) { var currentValues = GetEntityProperties(this, onlyTracked); var newValues = GetEntityProperties(values, onlyTracked); if (currentValues.Length != newValues.Length) { return(false); } foreach (var newValue in newValues) { var exists = currentValues.Any(x => x.name == newValue.name && !EqualityHelper.JsonCompare(x.value, newValue.value)); if (exists) { return(false); } } return(true); }