Beispiel #1
0
        public ColumnModel Column <T>(string name = null, bool?nullable = null, object defaultValue = null, bool primaryKey = false, bool autoIncrement = false)
        {
            Type columnType     = typeof(T);
            Type underlyingType = Nullable.GetUnderlyingType(columnType);

            if (underlyingType != null)
            {
                nullable   = nullable ?? true;
                columnType = underlyingType;
            }
            else if (!columnType.GetTypeInfo().IsValueType)
            {
                nullable = nullable ?? true;
            }
            else
            {
                nullable = nullable ?? false;
            }

            DataType type = Orm.GetDataType(columnType);

            return(new ColumnModel(name, type, nullable.Value, defaultValue, primaryKey, autoIncrement));
        }