Class MySqlCodeGenerator
A code generator responsible for producing SQL scripts for MySQL databases.
public class MySqlCodeGenerator : CodeGenerator, IVisitor, IDisposable
- Inheritance
-
MySqlCodeGenerator
- Implements
- Inherited Members
Constructors
MySqlCodeGenerator()
Initializes a new instance of the MySqlCodeGenerator class.
public MySqlCodeGenerator()
MySqlCodeGenerator(TextWriter)
Initializes a new instance of the MySqlCodeGenerator class with the specified TextWriter for output.
public MySqlCodeGenerator(TextWriter output)
Parameters
outputTextWriterThe TextWriter to which the generated SQL will be written. Must not be null.
MySqlCodeGenerator(string)
Initializes a new instance of the MySqlCodeGenerator class that writes output to a file at the specified path.
public MySqlCodeGenerator(string path)
Parameters
pathstringThe file path where the generated SQL will be written. Must not be null or empty.
Properties
GeneratesRowVersion
Gets a value indicating whether this code generator generates row version columns as part of the data export process.
protected override bool GeneratesRowVersion { get; }
Property Value
MySqlOptions
Represents configuration options specific to MySQL database generation.
public MySqlOptions MySqlOptions { get; }
Property Value
ProviderName
Gets the name of the database provider for which this code generator is designed to generate SQL scripts.
public override string ProviderName { get; }
Property Value
Methods
Format(object, ColumnType)
Formats a value for inclusion in a SQL statement, taking into account the value's type and the corresponding column type.
protected override string Format(object value, ColumnType columnType)
Parameters
valueobjectThe value to be formatted for inclusion in a SQL statement. This could be a default value for a column, a value being inserted into a table, or any other value that needs to be represented as a literal in the generated SQL. The method will determine how to format this value based on its type and the specified column type, ensuring that it is correctly represented in the SQL syntax for the target database provider.
columnTypeColumnTypeThe column type that corresponds to the value being formatted. This information is used to determine how to format the value, such as whether to quote it, how to format dates and times, how to represent binary data, etc., according to the conventions of the target database provider.
Returns
- string
A string representing the formatted value, ready to be included as a literal in a SQL statement, formatted according to the conventions of the target database provider.
GetTypeName(IDataItem)
Gets the SQL type name for the given data item, which could be a column or a user-defined data type.
protected override string GetTypeName(IDataItem item)
Parameters
itemIDataItemThe data item for which to determine the SQL type name. This could be a column or a user-defined data type. The method will use the properties of the data item, such as ColumnType, Size, Precision, and Scale, to determine the appropriate SQL type name, potentially using provider-specific type mappings and formatting rules.
Returns
- string
A string representing the SQL type name for the data item, formatted according to the conventions of the target database provider.
GetTypeReference(DataType)
Gets the SQL type reference for a user-defined data type, which may involve referencing the data type by name or using a specific syntax depending on the target database provider.
protected override string GetTypeReference(DataType dataType)
Parameters
dataTypeDataTypeThe user-defined data type for which to get the SQL type reference. This method is called when a column has a ColumnType of UserDefined, and the column's DataType property is not null. The method will determine how to reference this user-defined data type in the generated SQL, which may involve using the data type's name or a specific syntax depending on the conventions of the target database provider.
Returns
- string
A string representing the SQL type reference for the user-defined data type, formatted according to the conventions of the target database provider.
WriteIdentitySpecification(Column)
Writes the identity specification for the specified column.
protected override void WriteIdentitySpecification(Column column)
Parameters
columnColumnThe column for which the identity specification is being written.
WriteTableCreationSuffix(Table)
Writes any additional SQL syntax that should be included at the end of a CREATE TABLE statement for the given table.
protected override void WriteTableCreationSuffix(Table table)
Parameters
tableTableThe table for which to write the table creation suffix. This method can be overridden by derived classes to include additional syntax after the closing parenthesis of a CREATE TABLE statement, such as table options, storage engine specifications, or other provider-specific syntax that should be included when creating a table.