C# Class NMigrations.Sql.GenericSqlProvider

A general SQL generator implementation that implements the aspects that are common to all SQL dialects. Differences in SQL dialects are applied by subclassing GenericSqlProvider and overriding the specific methods.
Inheritance: ISqlProvider
Afficher le fichier Open project: sklose/NMigrations

Méthodes publiques

Méthode Description
GenerateSqlCommands ( Database database ) : IEnumerable

Generates the SQL commands for the specified database.

GetDefaultConstraintName ( string tableName, string columnName ) : string

Builds the name for a default constraint.

GetForeignKeyConstraintName ( string tableName, string columnNames, string relatedTableName, string relatedColumnNames ) : string

Builds the name for a foreign key constraint.

GetIndexName ( string tableName, string columnNames ) : string

Builds the name for an index.

GetPrimaryKeyConstraintName ( string tableName, string columnNames ) : string

Builds the name for a primary key constraint.

GetQuerySeparator ( ) : string

Gets the SQL command that separates multiple SQL queries in one SQL script file of each other.

GetUniqueConstraintName ( string tableName, string columnNames ) : string

Builds the name for a unique constraint.

Méthodes protégées

Méthode Description
AddDefaultConstraint ( DefaultConstraint defaultConstraint ) : IEnumerable

Enumerates the SQL commands that are necessary to create the specified defaultConstraint.

AddForeignKeyConstraint ( ForeignKeyConstraint fk ) : IEnumerable

Enumerates the SQL commands that are necessary to create the specified foreign key constraint (fk).

AddPrimaryKeyConstraint ( PrimaryKeyConstraint pk ) : IEnumerable

Enumerates the SQL commands that are necessary to create the specified primary key constraint (pk).

AddUniqueConstraint ( UniqueConstraint uniqueConstraint ) : IEnumerable

Enumerates the SQL commands that are necessary to create the specified uniqueConstraint.

AlterTable ( Table table ) : IEnumerable

Enumerates the SQL commands that are necessary to alter the specified table.

BuildAddColumn ( Column column ) : IEnumerable

Builds the SQL commands that adds the specified Column to its table.

BuildAlterColumnProperties ( Column column ) : IEnumerable

Builds the SQL commands that change the specified column's data type.

BuildAutoIncrement ( int seed, int step ) : string

Builds the SQL fragment that describes an auto-increment column.

BuildCreateTableColumn ( Column column ) : string

Builds the SQL fragment that describes a column in a CREATE TABLE statement.

BuildCreateTableConstraints ( Table table ) : IEnumerable

Builds the SQL fragments that follow after the column list in the CREATE TABLE statement (like constraints or indices).

BuildCreateTableForeignKeyConstraint ( ForeignKeyConstraint fk ) : string

Builds the SQL fragment that describes a foreign key constraint within a CREATE TABLE statement.

BuildCreateTablePrimaryKeyConstraint ( PrimaryKeyConstraint pk ) : string

Builds the SQL fragment that describes a primary key constraint within a CREATE TABLE statement.

BuildCreateTableUniqueConstraint ( UniqueConstraint uniqueConstraint ) : string

Builds the SQL fragment that describes a unqiue constraint within a CREATE TABLE statement.

BuildDataType ( SqlTypes type, int length, int scale, int precision ) : string

Builds the String that represents the specified type.

BuildDropColumn ( Column column ) : IEnumerable

Builds the SQL commands that drops the specified column from its table.

BuildDropDefault ( Column column ) : IEnumerable

Builds the SQL commands that drops the default value for the specified column.

BuildRenameColumn ( Column column ) : IEnumerable

Builds the SQL commands that renames the specified column.

CreateIndex ( System.Data.Common.Index index ) : IEnumerable

Enumerates the SQL commands that are necessary to create the specified index.

CreateTable ( Table table ) : IEnumerable

Enumerates the SQL commands that are necessary to create the specified table.

DropConstraint ( Constraint constraint ) : IEnumerable

Enumerates the SQL commands that are necessary to drop the specified constraint.

DropDefaultConstraint ( DefaultConstraint defaultConstraint ) : IEnumerable

Enumerates the SQL commands that are necessary to drop the specified defaultConstraint.

DropForeignKeyConstraint ( ForeignKeyConstraint fk ) : IEnumerable

Enumerates the SQL commands that are necessary to drop the specified foreign key constraint (fk).

DropIndex ( System.Data.Common.Index index ) : IEnumerable

Enumerates the SQL commands that are necessary to drop the specified index.

DropPrimaryKeyConstraint ( PrimaryKeyConstraint pk ) : IEnumerable

Enumerates the SQL commands that are necessary to drop the specified primary key constraint (pk).

DropTable ( Table table ) : IEnumerable

Enumerates the SQL commands that are necessary to drop the specified table.

DropUniqueConstraint ( UniqueConstraint uniqueConstraint ) : IEnumerable

Enumerates the SQL commands that are necessary to drop the specified uniqueConstraint.

EscapeColumnName ( string columnName ) : string

Escapes the specified columnName.

EscapeColumnNames ( string columnNames ) : string[]

Applies the EscapeColumnName method to an array of column names.

EscapeConstraintName ( string constraintName ) : string

Escapes the specified constraintName.

EscapeString ( string value ) : string

Escapes the specified string value that it can be surrounded by StringQuotes and used in a SQL query.

EscapeTableName ( string tableName ) : string

Escapes the specified tableName

ExecuteSqlStatement ( SqlStatement sql ) : IEnumerable

Enumerates the SQL commands that are necessary to execute the specified sql statement.

FormatValue ( object value ) : string

Formats the specified value according the described data type that it can be used in a SQL statement.

Insert ( Insert insert ) : IEnumerable

Generates the SQL statements that inserts the row described by the specified insert object into the database.

Update ( Update update ) : IEnumerable

Generates the SQL statements that updates rows described by the specified update object.

Method Details

AddDefaultConstraint() protected méthode

Enumerates the SQL commands that are necessary to create the specified defaultConstraint.
protected AddDefaultConstraint ( DefaultConstraint defaultConstraint ) : IEnumerable
defaultConstraint DefaultConstraint The default constraint.
Résultat IEnumerable

AddForeignKeyConstraint() protected méthode

Enumerates the SQL commands that are necessary to create the specified foreign key constraint (fk).
protected AddForeignKeyConstraint ( ForeignKeyConstraint fk ) : IEnumerable
fk ForeignKeyConstraint The foreign key constraint.
Résultat IEnumerable

AddPrimaryKeyConstraint() protected méthode

Enumerates the SQL commands that are necessary to create the specified primary key constraint (pk).
protected AddPrimaryKeyConstraint ( PrimaryKeyConstraint pk ) : IEnumerable
pk PrimaryKeyConstraint The primary key constraint.
Résultat IEnumerable

AddUniqueConstraint() protected méthode

Enumerates the SQL commands that are necessary to create the specified uniqueConstraint.
protected AddUniqueConstraint ( UniqueConstraint uniqueConstraint ) : IEnumerable
uniqueConstraint UniqueConstraint The unique constraint.
Résultat IEnumerable

AlterTable() protected méthode

Enumerates the SQL commands that are necessary to alter the specified table.
protected AlterTable ( Table table ) : IEnumerable
table Table The table to alter.
Résultat IEnumerable

BuildAddColumn() protected méthode

Builds the SQL commands that adds the specified Column to its table.
protected BuildAddColumn ( Column column ) : IEnumerable
column Column The column.
Résultat IEnumerable

BuildAlterColumnProperties() protected méthode

Builds the SQL commands that change the specified column's data type.
protected BuildAlterColumnProperties ( Column column ) : IEnumerable
column Column The column.
Résultat IEnumerable

BuildAutoIncrement() protected abstract méthode

Builds the SQL fragment that describes an auto-increment column.
protected abstract BuildAutoIncrement ( int seed, int step ) : string
seed int The initial value.
step int The increment step.
Résultat string

BuildCreateTableColumn() protected méthode

Builds the SQL fragment that describes a column in a CREATE TABLE statement.
protected BuildCreateTableColumn ( Column column ) : string
column Column The column.
Résultat string

BuildCreateTableConstraints() protected méthode

Builds the SQL fragments that follow after the column list in the CREATE TABLE statement (like constraints or indices).
protected BuildCreateTableConstraints ( Table table ) : IEnumerable
table Table The table.
Résultat IEnumerable

BuildCreateTableForeignKeyConstraint() protected méthode

Builds the SQL fragment that describes a foreign key constraint within a CREATE TABLE statement.
protected BuildCreateTableForeignKeyConstraint ( ForeignKeyConstraint fk ) : string
fk ForeignKeyConstraint The foreign key constraint.
Résultat string

BuildCreateTablePrimaryKeyConstraint() protected méthode

Builds the SQL fragment that describes a primary key constraint within a CREATE TABLE statement.
protected BuildCreateTablePrimaryKeyConstraint ( PrimaryKeyConstraint pk ) : string
pk PrimaryKeyConstraint The primary key constraint.
Résultat string

BuildCreateTableUniqueConstraint() protected méthode

Builds the SQL fragment that describes a unqiue constraint within a CREATE TABLE statement.
protected BuildCreateTableUniqueConstraint ( UniqueConstraint uniqueConstraint ) : string
uniqueConstraint UniqueConstraint The unique constraint.
Résultat string

BuildDataType() protected abstract méthode

Builds the String that represents the specified type.
protected abstract BuildDataType ( SqlTypes type, int length, int scale, int precision ) : string
type SqlTypes The type.
length int The length.
scale int The scale.
precision int The precision.
Résultat string

BuildDropColumn() protected méthode

Builds the SQL commands that drops the specified column from its table.
protected BuildDropColumn ( Column column ) : IEnumerable
column Column The column.
Résultat IEnumerable

BuildDropDefault() protected méthode

Builds the SQL commands that drops the default value for the specified column.
protected BuildDropDefault ( Column column ) : IEnumerable
column Column The column.
Résultat IEnumerable

BuildRenameColumn() protected méthode

Builds the SQL commands that renames the specified column.
protected BuildRenameColumn ( Column column ) : IEnumerable
column Column The column.
Résultat IEnumerable

CreateIndex() protected méthode

Enumerates the SQL commands that are necessary to create the specified index.
protected CreateIndex ( System.Data.Common.Index index ) : IEnumerable
index System.Data.Common.Index The index to create.
Résultat IEnumerable

CreateTable() protected méthode

Enumerates the SQL commands that are necessary to create the specified table.
protected CreateTable ( Table table ) : IEnumerable
table Table The table to create.
Résultat IEnumerable

DropConstraint() protected méthode

Enumerates the SQL commands that are necessary to drop the specified constraint.
protected DropConstraint ( Constraint constraint ) : IEnumerable
constraint Constraint The constraint to drop.
Résultat IEnumerable

DropDefaultConstraint() protected méthode

Enumerates the SQL commands that are necessary to drop the specified defaultConstraint.
protected DropDefaultConstraint ( DefaultConstraint defaultConstraint ) : IEnumerable
defaultConstraint DefaultConstraint The default constraint.
Résultat IEnumerable

DropForeignKeyConstraint() protected méthode

Enumerates the SQL commands that are necessary to drop the specified foreign key constraint (fk).
protected DropForeignKeyConstraint ( ForeignKeyConstraint fk ) : IEnumerable
fk ForeignKeyConstraint The foreign key constraint.
Résultat IEnumerable

DropIndex() protected méthode

Enumerates the SQL commands that are necessary to drop the specified index.
protected DropIndex ( System.Data.Common.Index index ) : IEnumerable
index System.Data.Common.Index The index to drop.
Résultat IEnumerable

DropPrimaryKeyConstraint() protected méthode

Enumerates the SQL commands that are necessary to drop the specified primary key constraint (pk).
protected DropPrimaryKeyConstraint ( PrimaryKeyConstraint pk ) : IEnumerable
pk PrimaryKeyConstraint The primary key constraint.
Résultat IEnumerable

DropTable() protected méthode

Enumerates the SQL commands that are necessary to drop the specified table.
protected DropTable ( Table table ) : IEnumerable
table Table The table to drop.
Résultat IEnumerable

DropUniqueConstraint() protected méthode

Enumerates the SQL commands that are necessary to drop the specified uniqueConstraint.
protected DropUniqueConstraint ( UniqueConstraint uniqueConstraint ) : IEnumerable
uniqueConstraint UniqueConstraint The unique constraint.
Résultat IEnumerable

EscapeColumnName() protected abstract méthode

Escapes the specified columnName.
protected abstract EscapeColumnName ( string columnName ) : string
columnName string Name of the column.
Résultat string

EscapeColumnNames() protected méthode

Applies the EscapeColumnName method to an array of column names.
protected EscapeColumnNames ( string columnNames ) : string[]
columnNames string The column names.
Résultat string[]

EscapeConstraintName() protected abstract méthode

Escapes the specified constraintName.
protected abstract EscapeConstraintName ( string constraintName ) : string
constraintName string Name of the constraint.
Résultat string

EscapeString() protected méthode

Escapes the specified string value that it can be surrounded by StringQuotes and used in a SQL query.
protected EscapeString ( string value ) : string
value string The string value to escape.
Résultat string

EscapeTableName() protected abstract méthode

Escapes the specified tableName
protected abstract EscapeTableName ( string tableName ) : string
tableName string Name of the table.
Résultat string

ExecuteSqlStatement() protected méthode

Enumerates the SQL commands that are necessary to execute the specified sql statement.
protected ExecuteSqlStatement ( SqlStatement sql ) : IEnumerable
sql SqlStatement The SQL statement.
Résultat IEnumerable

FormatValue() protected méthode

Formats the specified value according the described data type that it can be used in a SQL statement.
protected FormatValue ( object value ) : string
value object The value.
Résultat string

GenerateSqlCommands() public méthode

Generates the SQL commands for the specified database.
public GenerateSqlCommands ( Database database ) : IEnumerable
database Database The database.
Résultat IEnumerable

GetDefaultConstraintName() public méthode

Builds the name for a default constraint.
public GetDefaultConstraintName ( string tableName, string columnName ) : string
tableName string Name of the table.
columnName string The column name.
Résultat string

GetForeignKeyConstraintName() public méthode

Builds the name for a foreign key constraint.
public GetForeignKeyConstraintName ( string tableName, string columnNames, string relatedTableName, string relatedColumnNames ) : string
tableName string Name of the table.
columnNames string The column names.
relatedTableName string Name of the related table.
relatedColumnNames string The related column names.
Résultat string

GetIndexName() public méthode

Builds the name for an index.
public GetIndexName ( string tableName, string columnNames ) : string
tableName string Name of the table.
columnNames string The column names.
Résultat string

GetPrimaryKeyConstraintName() public méthode

Builds the name for a primary key constraint.
public GetPrimaryKeyConstraintName ( string tableName, string columnNames ) : string
tableName string Name of the table.
columnNames string The column names.
Résultat string

GetQuerySeparator() public abstract méthode

Gets the SQL command that separates multiple SQL queries in one SQL script file of each other.
public abstract GetQuerySeparator ( ) : string
Résultat string

GetUniqueConstraintName() public méthode

Builds the name for a unique constraint.
public GetUniqueConstraintName ( string tableName, string columnNames ) : string
tableName string Name of the table.
columnNames string The column names.
Résultat string

Insert() protected méthode

Generates the SQL statements that inserts the row described by the specified insert object into the database.
protected Insert ( Insert insert ) : IEnumerable
insert Insert The insert containing the row to insert.
Résultat IEnumerable

Update() protected méthode

Generates the SQL statements that updates rows described by the specified update object.
protected Update ( Update update ) : IEnumerable
update Update The update command.
Résultat IEnumerable