コード例 #1
0
ファイル: Tables.cs プロジェクト: zukky0008/Implem.Pleasanter
        internal static void CreateTable(
            string generalTableName,
            string sourceTableName,
            bool old,
            IEnumerable <ColumnDefinition> columnDefinitionCollection,
            IEnumerable <IndexInfo> tableIndexCollection,
            EnumerableRowCollection <DataRow> dbColumnCollection,
            string tableNameTemp = "")
        {
            Consoles.Write(sourceTableName, Consoles.Levels.Info);
            if (tableNameTemp == string.Empty)
            {
                tableNameTemp = sourceTableName;
            }
            var sqlCmd = new SqlCmd(
                Def.Code.Sql_CreateTable,
                SqlCmd.Types.PlainSql,
                Sqls.GetSqlParamCollection());

            sqlCmd.CreateColumn(sourceTableName, columnDefinitionCollection);
            sqlCmd.CreatePk(sourceTableName, columnDefinitionCollection, tableIndexCollection);
            sqlCmd.CreateIx(generalTableName, sourceTableName, old, columnDefinitionCollection);
            sqlCmd.CreateDefault(tableNameTemp, columnDefinitionCollection, dbColumnCollection);
            sqlCmd.DropConstraints(sourceTableName, tableIndexCollection);
            sqlCmd.CommandText = sqlCmd.CommandText.Replace("#TableName#", tableNameTemp);
            Def.GetSqlIoOfAdmin(transactional: true).ExecuteNonQuery(sqlCmd);
        }