Table of Contents

Class ServiceCollectionExtensions

Namespace
NextORM.Core
Assembly
nextorm.core.dll

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

services IServiceCollection

The service collection to register into.

optionsBuilder Action<DataContextBuilder>

Delegate that configures the builder.

serviceKey object

The key under which the context is registered.

Exceptions

ArgumentNullException

services or optionsBuilder is 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

services IServiceCollection

The service collection to register into.

optionsBuilder Action<IServiceProvider, DataContextBuilder>

Delegate that configures the builder using the current IServiceProvider.

serviceKey object

The key under which the context is registered.

Exceptions

ArgumentNullException

services or optionsBuilder is 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

services IServiceCollection

The service collection to register into.

serviceKey object

The key under which the context is registered.

Type Parameters

T

The concrete context type to register.

Exceptions

ArgumentNullException

services is 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

services IServiceCollection

The service collection to register into.

optionsBuilder Action<DataContextBuilder>

Delegate that configures the builder.

Exceptions

ArgumentNullException

services or optionsBuilder is 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

services IServiceCollection

The service collection to register into.

optionsBuilder Action<IServiceProvider, DataContextBuilder>

Delegate that configures the builder using the current IServiceProvider.

Exceptions

ArgumentNullException

services or optionsBuilder is 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

services IServiceCollection

The service collection to register into.

Type Parameters

T

The concrete context type to register.

Exceptions

ArgumentNullException

services is null.