| | | 1 | | using Microsoft.EntityFrameworkCore.Infrastructure; |
| | | 2 | | using Microsoft.Extensions.DependencyInjection; |
| | | 3 | | |
| | | 4 | | namespace ZhEaIsNsAaBn.Infrastructure.SqlServer; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Adds the SQL Server handlers (<see cref="IDbErrorClassifier"/>, <see cref="IStoredProcedureExecutor"/>, |
| | | 8 | | /// <see cref="IModelDefaultsProvider"/>) to one context's internal service provider. Contexts without it get none. |
| | | 9 | | /// </summary> |
| | | 10 | | internal sealed class SqlServerInfrastructureOptionsExtension : IDbContextOptionsExtension |
| | | 11 | | { |
| | | 12 | | private DbContextOptionsExtensionInfo? _info; |
| | | 13 | | |
| | | 14 | | |
| | 3074 | 15 | | public DbContextOptionsExtensionInfo Info => _info ??= new ExtensionInfo( this ); |
| | | 16 | | |
| | | 17 | | |
| | | 18 | | public void ApplyServices( IServiceCollection services ) |
| | | 19 | | { |
| | 27 | 20 | | services.AddSingleton<IDbErrorClassifier>( SqlServerDbErrorClassifier.Instance ); |
| | 27 | 21 | | services.AddSingleton<IStoredProcedureExecutor, SqlServerStoredProcedureExecutor>(); |
| | 27 | 22 | | services.AddSingleton<IModelDefaultsProvider, SqlServerModelDefaults>(); |
| | 27 | 23 | | } |
| | | 24 | | |
| | 27 | 25 | | public void Validate( IDbContextOptions options ) { } |
| | | 26 | | |
| | | 27 | | |
| | 262 | 28 | | private sealed class ExtensionInfo( IDbContextOptionsExtension extension ) : DbContextOptionsExtensionInfo( extensio |
| | | 29 | | { |
| | 27 | 30 | | public override bool IsDatabaseProvider => false; |
| | | 31 | | |
| | 0 | 32 | | public override string LogFragment => "using ZhEaIsNsAaBn SQL Server infrastructure "; |
| | | 33 | | |
| | 1136 | 34 | | public override int GetServiceProviderHashCode() => 0; |
| | | 35 | | |
| | 942 | 36 | | public override bool ShouldUseSameServiceProvider( DbContextOptionsExtensionInfo other ) => other is ExtensionIn |
| | | 37 | | |
| | | 38 | | public override void PopulateDebugInfo( IDictionary<string, string> debugInfo ) |
| | | 39 | | { |
| | 27 | 40 | | ArgumentNullException.ThrowIfNull( debugInfo ); |
| | | 41 | | |
| | 27 | 42 | | debugInfo[ "ZhEaIsNsAaBn:SqlServerInfrastructure" ] = "1"; |
| | 27 | 43 | | } |
| | | 44 | | } |
| | | 45 | | } |