コード例 #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ScriptMigration" /> class.
        /// </summary>
        /// <remarks>
        ///     <para>The arguments supported by <paramref name="args" /> are:</para>
        ///     <para><c>fromMigration</c>--The starting migration. Defaults to <see cref="Migration.InitialDatabase" />.</para>
        ///     <para><c>toMigration</c>--The ending migration. Defaults to the last migration.</para>
        ///     <para><c>idempotent</c>--Generate a script that can be used on a database at any migration.</para>
        ///     <para><c>noTransactions</c>--Don't generate SQL transaction statements.</para>
        ///     <para><c>contextType</c>--The <see cref="DbContext" /> to use.</para>
        /// </remarks>
        /// <param name="executor">The operation executor.</param>
        /// <param name="resultHandler">The <see cref="IOperationResultHandler" />.</param>
        /// <param name="args">The operation arguments.</param>
        public ScriptMigration(
            OperationExecutor executor,
            IOperationResultHandler resultHandler,
            IDictionary args)
            : base(resultHandler)
        {
            Check.NotNull(executor, nameof(executor));
            Check.NotNull(args, nameof(args));

            var fromMigration  = (string?)args["fromMigration"];
            var toMigration    = (string?)args["toMigration"];
            var idempotent     = (bool)args["idempotent"] !;
            var noTransactions = (bool)(args["noTransactions"] ?? false);
            var contextType    = (string?)args["contextType"];

            Execute(() => executor.ScriptMigrationImpl(fromMigration, toMigration, idempotent, noTransactions, contextType));
        }