コード例 #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="UpdateDatabase" /> class.
        /// </summary>
        /// <remarks>
        ///     <para>The arguments supported by <paramref name="args" /> are:</para>
        ///     <para>
        ///         <c>targetMigration</c>--The target <see cref="Migration" />. If <see cref="Migration.InitialDatabase" />, all migrations will be
        ///         reverted. Defaults to the last migration.
        ///     </para>
        ///     <para>
        ///         <c>connectionString</c>--The connection string to the database. Defaults to the one specified in
        ///         <see cref="O:Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.AddDbContext" /> or
        ///         <see cref="DbContext.OnConfiguring" />.
        ///     </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 UpdateDatabase(
            OperationExecutor executor,
            IOperationResultHandler resultHandler,
            IDictionary args)
            : base(resultHandler)
        {
            Check.NotNull(executor, nameof(executor));
            Check.NotNull(args, nameof(args));

            var targetMigration  = (string?)args["targetMigration"];
            var connectionString = (string?)args["connectionString"];
            var contextType      = (string?)args["contextType"];

            Execute(() => executor.UpdateDatabaseImpl(targetMigration, connectionString, contextType));
        }