コード例 #1
0
        /// <summary>
        /// Generate init string from contrains related to this column.
        /// </summary>
        /// <param name="column">Column attribute.</param>
        /// <param name="isForeignKey">FK attribute.</param>
        /// <param name="selfTableName">Name of holding table.</param>
        /// <returns>Generated SQL command.</returns>
        public static string ConstrainDeclarationCommand(
            ColumnAttribute column,
            IsForeignKeyAttribute isForeignKey,
            string selfTableName)
        {
            string command = "";

            command += "CONSTRAINT `" + isForeignKey.FKName(selfTableName) + "`\n";
            command += "\tFOREIGN KEY(`" + column.title + "`)\n";
            command += "\tREFERENCES `" + isForeignKey.schema + "`.`" + isForeignKey.table + "` (`" + isForeignKey.column + "`)\n";
            command += "\tON DELETE " + IsForeignKeyAttribute.ActionToCommand(isForeignKey.onDeleteCommand) + "\n";
            command += "\tON UPDATE " + IsForeignKeyAttribute.ActionToCommand(isForeignKey.onUpdateCommand);
            return(command);
        }
コード例 #2
0
        /// <summary>
        /// Return index init string suitable from forgeign key suitable for this column.
        /// </summary>
        /// <param name="column">Column attribute.</param>
        /// <param name="isForeignKey">FL attribute</param>
        /// <param name="selfTableName">Name of holding table.</param>
        /// <returns>Generated SQL command.</returns>
        public static string FKIndexDeclarationCommand(
            ColumnAttribute column,
            IsForeignKeyAttribute isForeignKey,
            string selfTableName)
        {
            // Generate comman
            string command = "INDEX `" +
                             isForeignKey.FKName(selfTableName) +
                             "_idx` (`" +
                             column.title +
                             "` ASC) VISIBLE";

            return(command);
        }