/// <summary> /// <para>Initializes a new instance of the <see cref="ScaffoldContext" /> class.</para> /// <para>The arguments supported by <paramref name="args" /> are:</para> /// <para><c>connectionString</c>--The connection string to the database.</para> /// <para><c>provider</c>--The provider to use.</para> /// <para><c>outputDir</c>--The directory to put files in. Paths are relative to the project directory.</para> /// <para><c>outputDbContextDir</c>--The directory to put DbContext file in. Paths are relative to the project directory.</para> /// <para><c>dbContextClassName</c>--The name of the DbContext to generate.</para> /// <para><c>schemaFilters</c>--The schemas of tables to generate entity types for.</para> /// <para><c>tableFilters</c>--The tables to generate entity types for.</para> /// <para><c>useDataAnnotations</c>--Use attributes to configure the model (where possible). If false, only the fluent API is used.</para> /// <para><c>overwriteFiles</c>--Overwrite existing files.</para> /// <para><c>useDatabaseNames</c>--Use table and column names directly from the database.</para> /// <para><c>modelNamespace</c>--Specify to override the namespace of the generated entity types.</para> /// <para><c>contextNamespace</c>--Specify to override the namespace of the generated DbContext class.</para> /// <para><c>noPluralize</c>--Don't use the pluralizer.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public ScaffoldContext( OperationExecutor executor, IOperationResultHandler resultHandler, IDictionary args) : base(resultHandler) { Check.NotNull(executor, nameof(executor)); Check.NotNull(args, nameof(args)); var connectionString = (string)args["connectionString"] !; var provider = (string)args["provider"] !; var outputDir = (string?)args["outputDir"]; var outputDbContextDir = (string?)args["outputDbContextDir"]; var dbContextClassName = (string?)args["dbContextClassName"]; var schemaFilters = (IEnumerable <string>)args["schemaFilters"] !; var tableFilters = (IEnumerable <string>)args["tableFilters"] !; var modelNamespace = (string?)args["modelNamespace"]; var contextNamespace = (string?)args["contextNamespace"]; var useDataAnnotations = (bool)args["useDataAnnotations"] !; var overwriteFiles = (bool)args["overwriteFiles"] !; var useDatabaseNames = (bool)args["useDatabaseNames"] !; var suppressOnConfiguring = (bool)(args["suppressOnConfiguring"] ?? false); var noPluralize = (bool)(args["noPluralize"] ?? false); Execute( () => executor.ScaffoldContextImpl( provider, connectionString, outputDir, outputDbContextDir, dbContextClassName, schemaFilters, tableFilters, modelNamespace, contextNamespace, useDataAnnotations, overwriteFiles, useDatabaseNames, suppressOnConfiguring, noPluralize)); }
/// <summary> /// <para>Initializes a new instance of the <see cref="GetContextTypes" /> class.</para> /// <para>No arguments are currently supported by <paramref name="args" />.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public GetContextTypes([NotNull] OperationExecutor executor, [NotNull] IOperationResultHandler resultHandler, [NotNull] IDictionary args) : base(resultHandler) { Check.NotNull(executor, nameof(executor)); Check.NotNull(args, nameof(args)); Execute(executor.GetContextTypesImpl); }
/// <summary> /// <para>Initializes a new instance of the <see cref="GetMigrations" /> class.</para> /// <para>The arguments supported by <paramref name="args" /> are:</para> /// <para><c>contextType</c>--The <see cref="DbContext" /> to use.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public GetMigrations([NotNull] OperationExecutor executor, [NotNull] IOperationResultHandler resultHandler, [NotNull] IDictionary args) : base(resultHandler) { Check.NotNull(executor, nameof(executor)); Check.NotNull(args, nameof(args)); var contextType = (string)args["contextType"]; Execute(() => executor.GetMigrationsImpl(contextType)); }
/// <summary> /// <para>Initializes a new instance of the <see cref="UpdateDatabase" /> class.</para> /// <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>contextType</c>--The <see cref="DbContext" /> to use.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public UpdateDatabase([NotNull] OperationExecutor executor, [NotNull] IOperationResultHandler resultHandler, [NotNull] IDictionary args) : base(resultHandler) { Check.NotNull(executor, nameof(executor)); Check.NotNull(args, nameof(args)); var targetMigration = (string)args["targetMigration"]; var contextType = (string)args["contextType"]; Execute(() => executor.UpdateDatabaseImpl(targetMigration, contextType)); }
/// <summary> /// <para>Initializes a new instance of the <see cref="ScriptDbContext" /> class.</para> /// <para>The arguments supported by <paramref name="args" /> are:</para> /// <para><c>contextType</c>--The <see cref="DbContext" /> to use.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public ScriptDbContext( OperationExecutor executor, IOperationResultHandler resultHandler, IDictionary args) : base(resultHandler) { Check.NotNull(executor, nameof(executor)); Check.NotNull(args, nameof(args)); var contextType = (string?)args["contextType"]; Execute(() => executor.ScriptDbContextImpl(contextType)); }
/// <summary> /// <para>Initializes a new instance of the <see cref="GetMigrations" /> class.</para> /// <para>The arguments supported by <paramref name="args" /> are:</para> /// <para><c>contextType</c>--The <see cref="DbContext" /> to use.</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>noConnect</c>--Don't connect to the database.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public GetMigrations( [NotNull] OperationExecutor executor, [NotNull] IOperationResultHandler resultHandler, [NotNull] IDictionary args) : base(resultHandler) { Check.NotNull(executor, nameof(executor)); Check.NotNull(args, nameof(args)); var contextType = (string)args["contextType"]; var connectionString = (string)args["connectionString"]; var noConnect = (bool)(args["noConnect"] ?? true); Execute(() => executor.GetMigrationsImpl(contextType, connectionString, noConnect)); }
/// <summary> /// <para>Initializes a new instance of the <see cref="RemoveMigration" /> class.</para> /// <para>The arguments supported by <paramref name="args" /> are:</para> /// <para><c>contextType</c>--The <see cref="DbContext" /> to use.</para> /// <para><c>force</c>--Don't check to see if the migration has been applied to the database.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public RemoveMigration( OperationExecutor executor, IOperationResultHandler resultHandler, IDictionary args) : base(resultHandler) { Check.NotNull(executor, nameof(executor)); Check.NotNull(args, nameof(args)); var contextType = (string?)args["contextType"]; var force = (bool)args["force"] !; Execute(() => executor.RemoveMigrationImpl(contextType, force)); }
/// <summary> /// <para>Initializes a new instance of the <see cref="Optimize" /> class.</para> /// <para>The arguments supported by <paramref name="args" /> are:</para> /// <para><c>outputDir</c>--The directory to put files in. Paths are relative to the project directory.</para> /// <para><c>modelNamespace</c>--Specify to override the namespace of the generated model.</para> /// <para><c>contextType</c>--The <see cref="DbContext" /> to use.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public Optimize( OperationExecutor executor, IOperationResultHandler resultHandler, IDictionary args) : base(resultHandler) { Check.NotNull(executor, nameof(executor)); Check.NotNull(args, nameof(args)); var outputDir = (string?)args["outputDir"]; var modelNamespace = (string?)args["modelNamespace"]; var contextType = (string?)args["contextType"]; Execute(() => executor.OptimizeImpl(outputDir, modelNamespace, contextType)); }
/// <summary> /// <para>Initializes a new instance of the <see cref="AddMigration" /> class.</para> /// <para>The arguments supported by <paramref name="args" /> are:</para> /// <para><c>name</c>--The name of the migration.</para> /// <para> /// <c>outputDir</c>--The directory (and sub-namespace) to use. Paths are relative to the project directory. Defaults to /// "Migrations". /// </para> /// <para><c>contextType</c>--The <see cref="DbContext" /> type to use.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public AddMigration( [NotNull] OperationExecutor executor, [NotNull] IOperationResultHandler resultHandler, [NotNull] IDictionary args) : base(resultHandler) { Check.NotNull(executor, nameof(executor)); Check.NotNull(args, nameof(args)); var name = (string)args["name"]; var outputDir = (string)args["outputDir"]; var contextType = (string)args["contextType"]; Execute(() => executor.AddMigrationImpl(name, outputDir, contextType)); }
/// <summary> /// <para>Initializes a new instance of the <see cref="ScriptMigration" /> class.</para> /// <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>contextType</c>--The <see cref="DbContext" /> to use.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public ScriptMigration( [NotNull] OperationExecutor executor, [NotNull] IOperationResultHandler resultHandler, [NotNull] 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 contextType = (string)args["contextType"]; Execute(() => executor.ScriptMigrationImpl(fromMigration, toMigration, idempotent, contextType)); }
/// <summary> /// <para>Initializes a new instance of the <see cref="ScriptMigration" /> class.</para> /// <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> /// </summary> /// <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)); }
/// <summary> /// <para>Initializes a new instance of the <see cref="ScaffoldContext" /> class.</para> /// <para>The arguments supported by <paramref name="args" /> are:</para> /// <para><c>connectionString</c>--The connection string to the database.</para> /// <para><c>provider</c>--The provider to use.</para> /// <para><c>outputDir</c>--The directory to put files in. Paths are relative to the project directory.</para> /// <para><c>outputDbContextDir</c>--The directory to put DbContext file in. Paths are relative to the project directory.</para> /// <para><c>dbContextClassName</c>--The name of the DbContext to generate.</para> /// <para><c>schemaFilters</c>--The schemas of tables to generate entity types for.</para> /// <para><c>tableFilters</c>--The tables to generate entity types for.</para> /// <para><c>useDataAnnotations</c>--Use attributes to configure the model (where possible). If false, only the fluent API is used.</para> /// <para><c>overwriteFiles</c>--Overwrite existing files.</para> /// <para><c>useDatabaseNames</c>--Use table and column names directly from the database.</para> /// </summary> /// <param name="executor"> The operation executor. </param> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> /// <param name="args"> The operation arguments. </param> public ScaffoldContext([NotNull] OperationExecutor executor, [NotNull] IOperationResultHandler resultHandler, [NotNull] IDictionary args) : base(resultHandler) { Check.NotNull(executor, nameof(executor)); Check.NotNull(args, nameof(args)); var connectionString = (string)args["connectionString"]; var provider = (string)args["provider"]; var outputDir = (string)args["outputDir"]; var outputDbContextDir = (string)args["outputDbContextDir"]; var dbContextClassName = (string)args["dbContextClassName"]; var schemaFilters = (IEnumerable <string>)args["schemaFilters"]; var tableFilters = (IEnumerable <string>)args["tableFilters"]; var useDataAnnotations = (bool)args["useDataAnnotations"]; var overwriteFiles = (bool)args["overwriteFiles"]; var useDatabaseNames = (bool)args["useDatabaseNames"]; Execute( () => executor.ScaffoldContextImpl( provider, connectionString, outputDir, outputDbContextDir, dbContextClassName, schemaFilters, tableFilters, useDataAnnotations, overwriteFiles, useDatabaseNames)); }
public MockOperation(IOperationResultHandler resultHandler, Func <T> action) : base(resultHandler) => Execute(action);
/// <summary> /// Initializes a new instance of the <see cref="OperationBase" /> class. /// </summary> /// <param name="resultHandler"> The <see cref="IOperationResultHandler" />. </param> protected OperationBase(IOperationResultHandler resultHandler) { Check.NotNull(resultHandler, nameof(resultHandler)); _resultHandler = resultHandler; }
/// <summary> /// Initializes a new instance of the <see cref="OperationBase" /> class. /// </summary> /// <param name="resultHandler">The <see cref="IOperationResultHandler" />.</param> protected OperationBase(IOperationResultHandler resultHandler) { _resultHandler = resultHandler; }
public MockOperation(IOperationResultHandler resultHandler, Action action) : base(resultHandler) { Execute(action); }
public MockOperation(IOperationResultHandler resultHandler, Func <IEnumerable <T> > action) : base(resultHandler) { Execute(action); }
public BooksController(ILibraryService bookService, IUserService userService, IOperationResultHandler operationHandler) { _bookService = bookService; _userService = userService; _operationHandler = operationHandler; }
protected OperationBase([NotNull] object resultHandler) { Check.NotNull(resultHandler, nameof(resultHandler)); _resultHandler = ForwardingProxy.Unwrap <IOperationResultHandler>(resultHandler); }