Browse Source

Merge pull request #24369 from abpframework/AbpDbContextOptions

Fix rel-10.0 merge problem.
pull/24373/head
Ma Liming 8 months ago
committed by GitHub
parent
commit
18624a96bf
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 49
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs

49
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContextOptions.cs

@ -26,14 +26,10 @@ public class AbpDbContextOptions
internal Dictionary<Type, List<object>> ConventionActions { get; }
internal Action<DbContext, ModelBuilder>? DefaultOnModelCreatingAction { get; set; }
internal Action<DbContext, DbContextOptionsBuilder>? DefaultOnConfiguringAction { get; set; }
internal Action<DbContext, DbContextOptionsBuilder>? DefaultOnConfiguringAction { get; set; }
internal Dictionary<Type, List<object>> OnModelCreatingActions { get; }
internal Dictionary<Type, List<object>> OnConfiguringActions { get; }
internal Action<DbContext, DbContextOptionsBuilder>? DefaultOnConfiguringAction { get; set; }
internal Dictionary<Type, List<object>> OnConfiguringActions { get; }
@ -108,27 +104,6 @@ public class AbpDbContextOptions
}
}
public void ConfigureDefaultOnConfiguring([NotNull] Action<DbContext, DbContextOptionsBuilder> action, bool overrideExisting = false)
{
Check.NotNull(action, nameof(action));
if (overrideExisting)
{
DefaultOnConfiguringAction = action;
}
else
{
DefaultOnConfiguringAction += action;
}
}
public void ConfigureDefaultOnConfiguring([NotNull] Action<DbContext, DbContextOptionsBuilder> action)
{
Check.NotNull(action, nameof(action));
DefaultOnConfiguringAction = action;
}
public void ConfigureOnModelCreating<TDbContext>([NotNull] Action<TDbContext, ModelBuilder> action)
where TDbContext : AbpDbContext<TDbContext>
{
@ -146,23 +121,19 @@ public class AbpDbContextOptions
actions.Add(action);
}
public void ConfigureOnConfiguring<TDbContext>([NotNull] Action<TDbContext, DbContextOptionsBuilder> action)
where TDbContext : AbpDbContext<TDbContext>
public void ConfigureDefaultOnConfiguring([NotNull] Action<DbContext, DbContextOptionsBuilder> action, bool overrideExisting = false)
{
Check.NotNull(action, nameof(action));
var actions = OnConfiguringActions.GetOrDefault(typeof(TDbContext));
if (actions == null)
if (overrideExisting)
{
OnConfiguringActions[typeof(TDbContext)] = new List<object>
{
new Action<DbContext, DbContextOptionsBuilder>((dbContext, builder) => action((TDbContext)dbContext, builder))
};
return;
DefaultOnConfiguringAction = action;
}
else
{
DefaultOnConfiguringAction += action;
}
actions.Add(action);
}
public void ConfigureOnConfiguring<TDbContext>([NotNull] Action<TDbContext, DbContextOptionsBuilder> action)

Loading…
Cancel
Save