Пример #1
0
        /// <summary>
        /// Adds an operation to create a new table.
        /// </summary>
        /// <typeparam name="TColumns"> The columns in this create table operation. You do not need to specify this type, it will be inferred from the columnsAction parameter you supply. </typeparam>
        /// <param name="name"> The name of the table. Schema name is optional, if no schema is specified then dbo is assumed. </param>
        /// <param name="columnsAction"> An action that specifies the columns to be included in the table. i.e. t => new { Id = t.Int(identity: true), Name = t.String() } </param>
        /// <param name="anonymousArguments"> Additional arguments that may be processed by providers. Use anonymous type syntax to specify arguments e.g. 'new { SampleArgument = "MyValue" }'. </param>
        public void AddTable <TColumns>(string name, Func <ColumnBuilder, TColumns> columnsAction, object anonymousArguments = null)
        {
            var dbMigration = new DbMigration();

            dbMigration.CreateTable(name, columnsAction, anonymousArguments);
            Sql(dbMigration.GetMigrationSql(SqlConnection));
        }
Пример #2
0
        /// <summary>
        ///     Adds an operation to create a new table.  This is a wrapper for the default DBMigration CreateTable.
        /// </summary>
        /// <typeparam name="TColumns"> The columns in this create table operation. You do not need to specify this type, it will be inferred from the columnsAction parameter you supply. </typeparam>
        /// <param name="name"> The name of the table. Schema name is optional, if no schema is specified then dbo is assumed. </param>
        /// <param name="columnsAction"> An action that specifies the columns to be included in the table. i.e. t => new { Id = t.Int(identity: true), Name = t.String() } </param>
        /// <param name="anonymousArguments"> Additional arguments that may be processed by providers. Use anonymous type syntax to specify arguments e.g. 'new { SampleArgument = "MyValue" }'. </param>
        /// <returns> An object that allows further configuration of the table creation operation. </returns>
        public TableBuilder <TColumns> CreateTable <TColumns>(string name, Func <ColumnBuilder, TColumns> columnsAction, object anonymousArguments = null)
        {
            DbMigration dbMigration = new DbMigration();
            var         table       = dbMigration.CreateTable(name, columnsAction, anonymousArguments);

            Sql(dbMigration.GetMigrationSql(SqlConnection));
            return(table);
        }