| | | 1 | | using Microsoft.EntityFrameworkCore.Infrastructure; |
| | | 2 | | using ZhEaIsNsAaBn.Infrastructure.SqlServer; |
| | | 3 | | |
| | | 4 | | // ReSharper disable once CheckNamespace |
| | | 5 | | namespace Microsoft.EntityFrameworkCore; |
| | | 6 | | |
| | | 7 | | /// <summary>Entry point of the SQL Server infrastructure provider.</summary> |
| | | 8 | | public static class SqlServerInfrastructureExtensions |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Gives this context the SQL Server handlers: SQL error classification for the <c>SafeExecution</c> ladder, parame |
| | | 12 | | /// stored procedures (<c>GetFromSql</c> / <c>OperateFromSql</c>) and model defaults (<c>CreatedDate</c> = <c>getdat |
| | | 13 | | /// <c>NEWSEQUENTIALID()</c>). Registered in the context's own service provider, so other contexts are not affected. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <example><code>options.UseSqlServer( connectionString ).UseSqlServerInfrastructure()</code></example> |
| | | 16 | | /// <param name="optionsBuilder">The context options builder.</param> |
| | | 17 | | /// <returns>The same builder.</returns> |
| | | 18 | | /// <exception cref="ArgumentNullException"><paramref name="optionsBuilder"/> is <see langword="null"/>.</exception> |
| | | 19 | | public static DbContextOptionsBuilder UseSqlServerInfrastructure( this DbContextOptionsBuilder optionsBuilder ) |
| | | 20 | | { |
| | 270 | 21 | | ArgumentNullException.ThrowIfNull( optionsBuilder ); |
| | | 22 | | |
| | 270 | 23 | | var extension = optionsBuilder.Options.FindExtension<SqlServerInfrastructureOptionsExtension>() ?? new SqlServer |
| | | 24 | | |
| | 270 | 25 | | ( (IDbContextOptionsBuilderInfrastructure) optionsBuilder ).AddOrUpdateExtension( extension ); |
| | | 26 | | |
| | | 27 | | |
| | 270 | 28 | | return optionsBuilder; |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <summary>Typed version of <see cref="UseSqlServerInfrastructure(DbContextOptionsBuilder)"/>.</summary> |
| | | 32 | | /// <typeparam name="TContext">The context type.</typeparam> |
| | | 33 | | /// <param name="optionsBuilder">The context options builder.</param> |
| | | 34 | | /// <returns>The same builder.</returns> |
| | | 35 | | /// <exception cref="ArgumentNullException"><paramref name="optionsBuilder"/> is <see langword="null"/>.</exception> |
| | | 36 | | public static DbContextOptionsBuilder<TContext> UseSqlServerInfrastructure< TContext >( this DbContextOptionsBuilder |
| | | 37 | | where TContext : DbContext |
| | 198 | 38 | | => (DbContextOptionsBuilder<TContext>) ( (DbContextOptionsBuilder) optionsBuilder ).UseSqlServerInfrastructure() |
| | | 39 | | } |