0
0

Remove unnecessary TSetting type parameter from ISettingsDbContext & just use ISetting instead

This commit is contained in:
Rhys Ickeringill
2025-12-28 16:45:14 +11:00
parent b7848d71d6
commit 0c824f268c
8 changed files with 25 additions and 31 deletions

View File

@@ -10,8 +10,7 @@ public static class ConfigurationBuilderExtensions
/// <summary>
/// Adds a <see cref="DbSet{}"/> off <typeparamref name="TDbContext"/> as a configuration provider to the <see cref="IConfigurationBuilder"/>.
/// </summary>
/// <typeparam name="TDbContext">Type of the <see cref="DbContext"/> which implements <see cref="ISettingsDbContext{,}"/></typeparam>
/// <typeparam name="TSetting">Concrete type which implements <see cref="ISetting"/></typeparam>
/// <typeparam name="TDbContext">Type of the <see cref="DbContext"/> which implements both <see cref="ISettingsDbContext{}"/> and <see cref="ISettingsDbContextFactory{}"/></typeparam>
/// <param name="optionsTransformer">
/// a <see cref="DbContextOptionsTransformer{}"/> which configures your <see cref="DbContextOptions{}"/>. eg.
/// <code>
@@ -19,12 +18,11 @@ public static class ConfigurationBuilderExtensions
/// </code>
/// </param>
/// <returns>The <see cref="IConfigurationBuilder"/></returns>
public static IConfigurationBuilder AddDbSet<TDbContext, TSetting>(this IConfigurationBuilder builder, DbContextOptionsTransformer<TDbContext> optionsTransformer)
where TDbContext : DbContext, ISettingsDbContext<DbSet<TSetting>, TSetting>, ISettingsDbContextFactory<TDbContext>
where TSetting : class, ISetting
public static IConfigurationBuilder AddDbContext<TDbContext>(this IConfigurationBuilder builder, DbContextOptionsTransformer<TDbContext> optionsTransformer)
where TDbContext : DbContext, ISettingsDbContext<System.Linq.IQueryable<ISetting>>, ISettingsDbContextFactory<TDbContext>
{
var options = optionsTransformer(new DbContextOptionsBuilder<TDbContext>()).Options;
var configurationSource = new EntityFrameworkCoreDbSetConfigurationSource<TDbContext, TSetting>()
var configurationSource = new EntityFrameworkCoreDbSetConfigurationSource<TDbContext>()
{
DbContextFactory = () => TDbContext.Create(options)
};