public EsentColumn AddColumn <T>(string name, Encoding encoding = null, int?max                   = null,
                                  object defaultValue            = null, EsentColumn.Option option = EsentColumn.Option.None)
 {
     CheckState();
     _columnsValid = false;
     return(EsentColumn.Create <T>(this, name, encoding, max, defaultValue, option));
 }
예제 #2
0
        internal static EsentColumn Create <T>(EsentTable table, string name, Encoding encoding, int?max, object defaultValue, Option option)
        {
            var columnType = typeof(T);
            var column     = new EsentColumn
            {
                Table        = table,
                Name         = name,
                ColumnType   = columnType,
                Encoding     = encoding,
                Max          = max,
                DefaultValue = defaultValue,
                JetDef       = { grbit = (ColumndefGrbit)option }
            };
            var defaultValueBytes = ValueProcessor.GetBytes(defaultValue, encoding);
            var defaultValueSize  = defaultValueBytes?.Length ?? 0;

            Api.JetAddColumn(table.Database.Session.JetId, table.JetId, name, column.JetDef, defaultValueBytes, defaultValueSize, out column.JetId);
            return(column);
        }
 public void DropColumn(string name)
 {
     CheckState();
     _columnsValid = false;
     EsentColumn.Drop(this, name);
 }