Beispiel #1
0
        public Column Add(string name, ColumnType type, ColumnQuantity quantity = ColumnQuantity.Single,
                          bool isNullable = true, bool isPrimaryKey = false, DbValue defaultValue = null)
        {
            var column = new Column(name, type, quantity, isNullable, isPrimaryKey, defaultValue);

            return(Add(column));
        }
Beispiel #2
0
 public Column(string name, ColumnType type, ColumnQuantity quantity)
     : this(name, type)
 {
     Quantity = quantity;
     if (quantity == ColumnQuantity.List)
     {
         _dbType = ColumnType.BLOB.ToDbString();
     }
 }
Beispiel #3
0
 public Column(string name, ColumnType type, ColumnQuantity quantity, bool isNullable, bool isKey, DbValue defaultValue)
     : this(name, type, isNullable, isKey, defaultValue)
 {
     Quantity = quantity;
     if (quantity == ColumnQuantity.List)
     {
         _dbType = ColumnType.BLOB.ToDbString();
     }
 }
Beispiel #4
0
 internal Column(Table table, string name, ColumnType type, ColumnQuantity quantity, bool isNullable, bool isKey, string defaultValue)
 {
     Table         = table;
     _name         = name;
     _dbType       = (quantity == ColumnQuantity.List) ? ColumnType.BLOB.ToDbString() : type.ToDbString();
     _type         = type;
     _quantity     = quantity;
     _isNullable   = isNullable;
     _isPrimaryKey = isKey;
     _defaultValue = ParseDefaultValue(defaultValue);
 }
Beispiel #5
0
        internal static DbValue FromDb(object value, ColumnType type, ColumnQuantity quantity)
        {
            DbValue newValue;

            if (value is DBNull)
            {
                newValue = null;
            }
            else if (quantity == ColumnQuantity.List)
            {
                newValue = UnpackArray((byte[])value, type);
            }
            else if (value is long)
            {
                newValue = (long)value;
            }
            else if (value is string)
            {
                newValue = (string)value;
            }
            else if (value is byte[])
            {
                newValue = (byte[])value;
            }
            else if (value is double)
            {
                newValue = (double)value;
            }
            else if (value is decimal)
            {
                newValue = (decimal)value;
            }
            else
            {
                throw new ArgumentException("Unknown database type {0}".FormatExt(value.GetType()), "value");
            }
            return(newValue);
        }