public override object ToUpdate(object entity, bool refreshField) { var value = Handler.Get(entity); object result; var useDef = false; if (Equals(value, null)) { if (IsNullable) { result = null; } else { useDef = true; result = _minValue; } } else if (_isTimeStamp && _defaultTimeFunction != null) { useDef = true; result = _defaultTimeFunction.GetValue(); } else { result = value; } if (useDef && refreshField) { Handler.Set(entity, result); } return(result); }
public override object GetInsertData(object entity, bool refreshField) { object value = Handler.Get(entity); object result; bool useDef = false; if (Object.Equals(value, null)) { if (_defaultValue != null) { useDef = true; if (_typeCode == TypeCode.DateTime && _defaultTimeFunction != null) { result = _defaultTimeFunction.GetValue(); } else { result = _defaultValue; } } else { if (IsNullable) { result = null; } else { useDef = true; result = _minValue; } } } else if (_typeCode == TypeCode.DateTime && Object.Equals(value, DateTime.MinValue)) { if (_defaultTimeFunction != null) { useDef = true; result = this._defaultTimeFunction.GetValue(); } else if (_defaultValue != null) { useDef = true; result = _defaultValue; } else { result = value; } } else if (isTimeStamp) { useDef = true; result = this._defaultTimeFunction.GetValue(); } else { result = value; } if (useDef && refreshField) { Handler.Set(entity, result); } return(result); }