/// <summary> /// Constructor. /// </summary> protected DbCreateStoredProcedureTemplate(IDbSetup setup, Type tableTemplate, StoredProcedureFunction function) : base(setup) { TableTemplate = tableTemplate; Binding = setup.GetTableBinding(tableTemplate); SqlTableName = Binding.GetSqlTableName(); SqlSpName = Binding.GetSqlTableSpName(function); }
/// <summary> /// Constructor. /// </summary> public DropStoredProcedure(IDbSetup setup, Type tableTemplate, StoredProcedureFunction function, bool onlyIfExists = false) : base(setup) { var binding = setup.GetTableBinding(tableTemplate); Name = setup.Naming.GetStoredProcedureName(binding.TableName, function); OnlyIfExists = onlyIfExists; }
/// <summary> /// Get the primary key column type. /// </summary> public static IDbColumnBinding GetPrimaryKeyColumn(IDbSetup setup, Type tableType) { var binding = setup.GetTableBinding(tableType); var col = binding?.SingleColumnPrimaryKey; if (col == null) { throw new ArgumentException($"Unknown type/foreign key for [{tableType.Name}]"); } return(col); }
/// <summary> /// Constructor. /// </summary> public CreateTable(IDbSetup setup, Type tableTemplate) : base(setup) { var tableAttr = TypeHelper.TryGetAttribute <MySqlTableAttribute>(tableTemplate, true); Engine = (tableAttr?.Engine ?? Custom.MySql.Engine.InnoDb).ToString(); DefaultCharset = (tableAttr?.DefaultCharset ?? DefaultKey); var bindings = setup.GetTableBinding(tableTemplate); TableName = bindings.TableName; ColumnDefinition = GetColumnDefinition(bindings.Columns); TableConstraints = GetTableConstraints(bindings); }