File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime/Extensions Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ using Microsoft . EntityFrameworkCore . Infrastructure ;
2+ using Microsoft . EntityFrameworkCore . SqlServer . Infrastructure ;
3+ using Microsoft . Extensions . DependencyInjection ;
4+
5+ namespace Microsoft . EntityFrameworkCore ;
6+
7+ public static class AzureSqlDbContextOptionsBuilderExtensions
8+ {
9+ public static AzureSqlDbContextOptionsBuilder UseNodaTime (
10+ this AzureSqlDbContextOptionsBuilder azureBuilder )
11+ {
12+ // Access the underlying OptionsBuilder
13+ var coreOptionsBuilder = ( ( IRelationalDbContextOptionsBuilderInfrastructure ) azureBuilder ) . OptionsBuilder ;
14+
15+ // Look for the NodaTime extension or create a new instance if not found
16+ var extension = coreOptionsBuilder . Options . FindExtension < NodaTimeOptionsExtension > ( )
17+ ?? new NodaTimeOptionsExtension ( ) ;
18+
19+ // Add or update the extension in the options
20+ ( ( IDbContextOptionsBuilderInfrastructure ) coreOptionsBuilder ) . AddOrUpdateExtension ( extension ) ;
21+
22+ return azureBuilder ;
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments