I have a bool variable _settings.Value.UsePostgreSQL
and method
AddConfiguration(this IServiceCollection builder, Action<DbContextOptionsBuilder> dbContextOptionsAction = null)
Is it possible to use if
condition in method with Action
as a parameter? Something like this:
_settings.Value.UsePostgreSQL = true;
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
services.AddConfiguration(builder =>
_settings.Value.UsePostgreSQL ?
builder.UseSqlServer(_settings.Value.ConnectionString, options =>
options.MigrationsAssembly(migrationsAssembly)) :
builder.UseNpgsql(_settings.Value.ConnectionString, options =>
options.MigrationsAssembly(migrationsAssembly)));
While I'm trying to implement this I have an error:
Only assignment, call, increment, decrement, and new object expressions can be used as a statement