Exemplo n.º 1
0
        public void CreateTable()
        {
            if (mDbMgr.TableExists(mTablename))
            {
                return;
            }

            DbGenerateTableStatement clause = mDbMgr.CreateGenerateTableClause();

            clause
            .CreateTable(mTablename)
            .WithPrimaryKey(mPrimaryKey);

            foreach (string fieldname in mFields.Keys)
            {
                clause.WithField(fieldname, mFields[fieldname]);
            }

            foreach (string fieldname in mForeignKeys.Keys)
            {
                clause.WithReference(fieldname, mForeignKeys[fieldname]);
            }

            mDbMgr.ExecuteNonQuery(clause);
        }
Exemplo n.º 2
0
        public void RecreateTable()
        {
            if (mDbMgr.TableExists(mTablename))
            {
                mDbMgr.ExecuteNonQuery(mDbMgr.CreateDropTable().DropTable(mTablename));
            }

            DbGenerateTableStatement clause = BuildClause();

            mDbMgr.ExecuteNonQuery(clause);
        }
Exemplo n.º 3
0
        protected virtual DbGenerateTableStatement BuildClause()
        {
            DbGenerateTableStatement clause = mDbMgr.CreateGenerateTableClause();

            clause
            .CreateTable(mTablename)
            .WithPrimaryKey(mPrimaryKey);

            foreach (string fieldname in mFields.Keys)
            {
                clause.WithField(fieldname, mFields[fieldname]);
            }

            foreach (string fieldname in mForeignKeys.Keys)
            {
                clause.WithReference(fieldname, mForeignKeys[fieldname]);
            }

            return(clause);
        }
Exemplo n.º 4
0
        public override string ToString()
        {
            DbGenerateTableStatement clause = BuildClause();

            return(string.Format("TableCmd: {0}", clause.ToString()));
        }