| | | 1 | | // ReSharper disable once CheckNamespace |
| | | 2 | | namespace Microsoft.Extensions.DependencyInjection; |
| | | 3 | | |
| | | 4 | | /// <summary>Core-builder entry point of the SQL Server infrastructure provider.</summary> |
| | | 5 | | public static class SqlServerInfrastructureRegistration |
| | | 6 | | { |
| | | 7 | | /// <summary> |
| | | 8 | | /// Gives the context of this builder (the most recent <c>WithDbContext<T>()</c>) the SQL Server handlers. Onl |
| | | 9 | | /// <c>Build()</c> adds <c>UseSqlServerInfrastructure()</c> to that context's options in every mode (scoped, custom, |
| | | 10 | | /// Other contexts are not affected. Calling it twice adds the handlers once. |
| | | 11 | | /// </summary> |
| | | 12 | | /// <example><code>services.AddInfrastructureCore().WithDbContext<AppDbContext>( o => o.UseSqlServer( cs ) |
| | | 13 | | /// <typeparam name="TDbContext">The context type.</typeparam> |
| | | 14 | | /// <param name="builder">The builder of the context.</param> |
| | | 15 | | /// <returns>The same builder.</returns> |
| | | 16 | | /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null"/>.</exception> |
| | | 17 | | public static IInfrastructureBuilder<TDbContext> WithSqlServer< TDbContext >( this IInfrastructureBuilder<TDbContext |
| | | 18 | | where TDbContext : DbContext |
| | | 19 | | { |
| | 44 | 20 | | ArgumentNullException.ThrowIfNull( builder ); |
| | | 21 | | |
| | 40 | 22 | | return builder.ConfigureDbContextOptions( options => options.UseSqlServerInfrastructure() ); |
| | | 23 | | } |
| | | 24 | | } |