Class ServiceCollectionExtensions
Registration helpers for nextorm contexts.
Invariants:
- a concrete context type is registered once per scope: resolving the concrete type and IDataContext yields the same instance (previously they were two separate instances);
- the options delegate is mandatory for factory-based registration — a DataContextBuilder without options can never produce a context, so a null delegate now fails at registration time instead of at resolution time.
public static class ServiceCollectionExtensions
- Inheritance
-
ServiceCollectionExtensions
- Inherited Members
Methods
AddKeyedNextOrmContext(IServiceCollection, Action<DataContextBuilder>, object?)
Registers a keyed IDataContext (and its scoped DataContextBuilder)
configured by optionsBuilder.
public static void AddKeyedNextOrmContext(this IServiceCollection services, Action<DataContextBuilder> optionsBuilder, object? serviceKey)
Parameters
servicesIServiceCollectionThe service collection to register into.
optionsBuilderAction<DataContextBuilder>Delegate that configures the builder.
serviceKeyobjectThe key under which the context is registered.
Exceptions
- ArgumentNullException
servicesoroptionsBuilderis null.
AddKeyedNextOrmContext(IServiceCollection, Action<IServiceProvider, DataContextBuilder>, object?)
Registers a keyed IDataContext (and its scoped DataContextBuilder)
configured by optionsBuilder, which may resolve services from the provider.
public static void AddKeyedNextOrmContext(this IServiceCollection services, Action<IServiceProvider, DataContextBuilder> optionsBuilder, object? serviceKey)
Parameters
servicesIServiceCollectionThe service collection to register into.
optionsBuilderAction<IServiceProvider, DataContextBuilder>Delegate that configures the builder using the current IServiceProvider.
serviceKeyobjectThe key under which the context is registered.
Exceptions
- ArgumentNullException
servicesoroptionsBuilderis null.
AddKeyedNextOrmContext<T>(IServiceCollection, object?)
Registers the concrete context type T under a key once per scope and
forwards the keyed IDataContext to it, so both resolve to the same instance.
public static void AddKeyedNextOrmContext<T>(this IServiceCollection services, object? serviceKey) where T : class, IDataContext
Parameters
servicesIServiceCollectionThe service collection to register into.
serviceKeyobjectThe key under which the context is registered.
Type Parameters
TThe concrete context type to register.
Exceptions
- ArgumentNullException
servicesis null.
AddNextOrmContext(IServiceCollection, Action<DataContextBuilder>)
Registers an unkeyed IDataContext (and its scoped DataContextBuilder)
configured by optionsBuilder.
public static void AddNextOrmContext(this IServiceCollection services, Action<DataContextBuilder> optionsBuilder)
Parameters
servicesIServiceCollectionThe service collection to register into.
optionsBuilderAction<DataContextBuilder>Delegate that configures the builder.
Exceptions
- ArgumentNullException
servicesoroptionsBuilderis null.
AddNextOrmContext(IServiceCollection, Action<IServiceProvider, DataContextBuilder>)
Registers an unkeyed IDataContext (and its scoped DataContextBuilder)
configured by optionsBuilder, which may resolve services from the provider.
public static void AddNextOrmContext(this IServiceCollection services, Action<IServiceProvider, DataContextBuilder> optionsBuilder)
Parameters
servicesIServiceCollectionThe service collection to register into.
optionsBuilderAction<IServiceProvider, DataContextBuilder>Delegate that configures the builder using the current IServiceProvider.
Exceptions
- ArgumentNullException
servicesoroptionsBuilderis null.
AddNextOrmContext<T>(IServiceCollection)
Registers the concrete context type T once per scope and forwards
IDataContext to it, so both resolve to the same instance.
public static void AddNextOrmContext<T>(this IServiceCollection services) where T : class, IDataContext
Parameters
servicesIServiceCollectionThe service collection to register into.
Type Parameters
TThe concrete context type to register.
Exceptions
- ArgumentNullException
servicesis null.