Пример #1
0
        protected override void OnValidateSetDefaultValue(object value)
        {
            base.OnValidateSetDefaultValue(value);

            var cremaType = this.CremaType;

            if (cremaType != null)
            {
                if (value != null && value != DBNull.Value)
                {
                    if (value is string)
                    {
                        cremaType.ValidateValue(value as string);
                    }
                    else if (CremaConvert.VerifyChangeType(value, typeof(long)) == false)
                    {
                        throw new ArgumentException($"'{value}'은(는) 잘못된 기본값입니다.");
                    }
                    else
                    {
                        var n = (long)CremaConvert.ChangeType(value, typeof(long));
                        if (cremaType.ConvertToString(n) == $"{n}")
                        {
                            throw new ArgumentException($"'{value}'은(는) 잘못된 기본값입니다.");
                        }
                    }
                }
            }
        }
Пример #2
0
 private object GetDefaultValue(ColumnInfo columnInfo)
 {
     if (columnInfo.DefaultValue != null && CremaDataTypeUtility.IsBaseType(columnInfo.DataType) == true)
     {
         var type = CremaDataTypeUtility.GetType(columnInfo.DataType);
         return(CremaConvert.ChangeType(columnInfo.DefaultValue, type));
     }
     return(columnInfo.DefaultValue);
 }