Ejemplo n.º 1
0
 private bool AllTablesExist(DBStructure structure)
 {
     foreach (string tableName in new string[] { "PropTypes", "ResourceTypes",
                                                 "IntProps", "StringProps", "LongStringProps",
                                                 "StringListProps", "DateProps", "BlobProps",
                                                 "DoubleProps", "Resources", "Links" })
     {
         try
         {
             structure.GetTable(tableName);
         }
         catch (TableDoesNotExistException)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
        public void DropCompoundAndCreateWithValue( )
        {
            _testTable = m_database.GetTable("People");
            IRecord record = null;

            for (int i = 0; i < 10; i++)
            {
                record = _testTable.NewRecord();
                Assert.AreEqual(i, record.GetID());
                record.SetValue(Id, i);
                record.SetValue(Type, i);
                record.SetValue(Number, i * 100);
                record.Commit();
                Assert.AreEqual(i + 1, _testTable.Count);
            }
            record = _testTable.GetRecordByEqual(0, 2);
            Assert.AreEqual(2, record.GetIntValue(1));
            Assert.AreEqual(200, record.GetIntValue(2));
            ICountedResultSet resultSet = _testTable.CreateResultSet(0, 2, 1, 2, false);

            Assert.AreEqual(1, resultSet.Count);
            record = resultSet[0];
            Assert.AreEqual(2, record.GetIntValue(1));
            Assert.AreEqual(200, record.GetIntValue(2));
            resultSet.Dispose();

            m_database.Shutdown();

            DBStructure database = new DBStructure("", "MyPal");

            database.LoadStructure();

            m_database = database.Database;
            _testTable = m_database.GetTable("People");

            record = _testTable.GetRecordByEqual(0, 2);
            Assert.AreEqual(2, record.GetIntValue(1));
            Assert.AreEqual(200, record.GetIntValue(2));

            m_database.Shutdown();
            database = new DBStructure("", "MyPal");
            database.LoadStructure();

            m_database = database.Database;
            TableStructure tblStruct = database.GetTable("People");

            tblStruct.DropCompoundIndex("Id", "Type");
            tblStruct.SetCompoundIndexWithValue("Id", "Type", "Number");
            _testTable = m_database.GetTable("People");
            database.SaveStructure();
            m_database.Shutdown();
            database.RebuildIndexes(true);

            database = new DBStructure("", "MyPal");
            database.LoadStructure();
            m_database = database.Database;
            _testTable = m_database.GetTable("People");
            Assert.AreEqual(10, _testTable.Count);
            record = _testTable.GetRecordByEqual(0, 2);
            Assert.AreEqual(2, record.GetIntValue(1));
            Assert.AreEqual(200, record.GetIntValue(2));
        }