コード例 #1
0
        internal void OpenTable(IDatabaseDesign dbDesign)
        {
            Table tableDesign = (Table)dbDesign.CreateTable(Name, this);

            _table = tableDesign;
            foreach (HashMap.Entry entry in _columns)
            {
                ColumnStructure colStructure = (ColumnStructure)entry.Value;
                Column          column       = colStructure.MakeColumn(tableDesign, colStructure.Name);
                tableDesign.AddColumn(column);
                if (colStructure.HasIndex)
                {
                    IDBIndex dbIndex =
                        new DBIndex(tableDesign, colStructure.Name, column.GetFixedFactory(), null, null, null);
                    tableDesign.AddIndex(colStructure.Name, dbIndex);
                }
            }
            tableDesign.CheckTableLength();
            foreach (HashMap.Entry entry in _compoundIndexes)
            {
                string   firstName    = (string)entry.Key;
                Column   firstColumn  = tableDesign.GetColumn(firstName);
                string   secondName   = (string)entry.Value;
                Column   secondColumn = tableDesign.GetColumn(secondName);
                string   compoundName = firstName + "#" + secondName;
                IDBIndex dbIndex      =
                    new DBIndex(tableDesign, compoundName,
                                new FixedLengthKey_Compound(firstColumn.GetFixedFactory(), secondColumn.GetFixedFactory()),
                                firstColumn.GetFixedFactory(), secondColumn.GetFixedFactory(), null);
                tableDesign.AddCompoundIndex(compoundName, dbIndex);
            }
            foreach (HashMap.Entry entry in _compoundIndexesWithValue)
            {
                string            firstName         = (string)entry.Key;
                Column            firstColumn       = tableDesign.GetColumn(firstName);
                CompoundWithValue compoundWithValue = (CompoundWithValue)entry.Value;
                string            secondName        = compoundWithValue.secondColumn;
                Column            secondColumn      = tableDesign.GetColumn(secondName);
                Column            valueColumn       = tableDesign.GetColumn(compoundWithValue.valueColumn);
                string            compoundName      = firstName + "#" + secondName;
                IDBIndex          dbIndex           =
                    new DBIndex(tableDesign, compoundName,
                                new FixedLengthKey_CompoundWithValue(firstColumn.GetFixedFactory(), secondColumn.GetFixedFactory(), valueColumn.GetFixedFactory()),
                                firstColumn.GetFixedFactory(), secondColumn.GetFixedFactory(), valueColumn.GetFixedFactory());
                tableDesign.AddCompoundIndexWithValue(compoundName, dbIndex, valueColumn.Name);
            }
            if (!tableDesign.Dirty)
            {
                try
                {
                    tableDesign.OpenIndexes();
                }
                catch (BadIndexesException)
                {
                    _dirty = true;
                }
            }
        }
コード例 #2
0
ファイル: DBStructure.cs プロジェクト: mo5h/omeo
 private void InitDatabase()
 {
     if (_database == null)
     {
         _database = new Database(this);
         IDatabaseDesign dbDesign = _database;
         foreach (HashMap.Entry entry in _tables)
         {
             try
             {
                 ((TableStructure)entry.Value).OpenTable(dbDesign);
             }
             catch (IndexIsCorruptedException) {}
         }
     }
     _database.ProgressListenerEvent += new Database.ProgressEventHandler(OnRebuildProgress);
 }
コード例 #3
0
ファイル: DBStructure.cs プロジェクト: mo5h/omeo
 private Database OpenDatabaseInternal()
 {
     _dbMode = DatabaseMode.Open;
     if (_database == null)
     {
         _database = new Database(this);
         IDatabaseDesign dbDesign = _database;
         foreach (HashMap.Entry entry in _tables)
         {
             try
             {
                 ((TableStructure)entry.Value).OpenTable(dbDesign);
             }
             catch (IndexIsCorruptedException exception)
             {
                 _tracer.TraceException(exception);
                 _dirty = true;
             }
         }
     }
     return(_database);
 }