Sdílet prostřednictvím


EntityFrameworkServicesBuilder.TryAdd Method

Definition

Overloads

TryAdd(Type, Object)

Adds an implementation of an Entity Framework service only if one has not already been registered. This method can only be used for singleton services.

TryAdd(Type, Type)

Adds an implementation of an Entity Framework service only if one has not already been registered. The scope of the service is automatically defined by Entity Framework.

TryAdd(Type, Type, Func<IServiceProvider,Object>)

Adds a factory for an Entity Framework service only if one has not already been registered. The scope of the service is automatically defined by Entity Framework.

TryAdd<TService,TImplementation>()

Adds an implementation of an Entity Framework service only if one has not already been registered. The scope of the service is automatically defined by Entity Framework.

TryAdd<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Adds a factory for an Entity Framework service only if one has not already been registered. The scope of the service is automatically defined by Entity Framework.

TryAdd<TService>(Func<IServiceProvider,TService>)

Adds a factory for an Entity Framework service only if one has not already been registered. The scope of the service is automatically defined by Entity Framework.

TryAdd<TService>(TService)

Adds an implementation of an Entity Framework service only if one has not already been registered. This method can only be used for singleton services.

TryAdd(Type, Object)

Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs

Adds an implementation of an Entity Framework service only if one has not already been registered. This method can only be used for singleton services.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder TryAdd (Type serviceType, object implementation);
abstract member TryAdd : Type * obj -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder
override this.TryAdd : Type * obj -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder
Public Overridable Function TryAdd (serviceType As Type, implementation As Object) As EntityFrameworkServicesBuilder

Parameters

serviceType
Type

The contract for the service.

implementation
Object

The implementation of the service.

Returns

This builder, such that further calls can be chained.

Remarks

See Implementation of database providers and extensions for more information and examples.

Applies to

TryAdd(Type, Type)

Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs

Adds an implementation of an Entity Framework service only if one has not already been registered. The scope of the service is automatically defined by Entity Framework.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder TryAdd (Type serviceType, Type implementationType);
abstract member TryAdd : Type * Type -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder
override this.TryAdd : Type * Type -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder
Public Overridable Function TryAdd (serviceType As Type, implementationType As Type) As EntityFrameworkServicesBuilder

Parameters

serviceType
Type

The contract for the service.

implementationType
Type

The concrete type that implements the service.

Returns

This builder, such that further calls can be chained.

Remarks

See Implementation of database providers and extensions for more information and examples.

Applies to

TryAdd(Type, Type, Func<IServiceProvider,Object>)

Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs

Adds a factory for an Entity Framework service only if one has not already been registered. The scope of the service is automatically defined by Entity Framework.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder TryAdd (Type serviceType, Type implementationType, Func<IServiceProvider,object> factory);
abstract member TryAdd : Type * Type * Func<IServiceProvider, obj> -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder
override this.TryAdd : Type * Type * Func<IServiceProvider, obj> -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder
Public Overridable Function TryAdd (serviceType As Type, implementationType As Type, factory As Func(Of IServiceProvider, Object)) As EntityFrameworkServicesBuilder

Parameters

serviceType
Type

The contract for the service.

implementationType
Type

The concrete type that implements the service.

factory
Func<IServiceProvider,Object>

The factory that will create the service instance.

Returns

This builder, such that further calls can be chained.

Remarks

See Implementation of database providers and extensions for more information and examples.

Applies to

TryAdd<TService,TImplementation>()

Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs

Adds an implementation of an Entity Framework service only if one has not already been registered. The scope of the service is automatically defined by Entity Framework.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder TryAdd<TService,TImplementation> () where TService : class where TImplementation : class, TService;
abstract member TryAdd : unit -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder (requires 'Service : null)
override this.TryAdd : unit -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder (requires 'Service : null)
Public Overridable Function TryAdd(Of TService As Class, TImplementation As Class) () As EntityFrameworkServicesBuilder

Type Parameters

TService

The contract for the service.

TImplementation

The concrete type that implements the service.

Returns

This builder, such that further calls can be chained.

Remarks

See Implementation of database providers and extensions for more information and examples.

Applies to

TryAdd<TService,TImplementation>(Func<IServiceProvider,TImplementation>)

Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs

Adds a factory for an Entity Framework service only if one has not already been registered. The scope of the service is automatically defined by Entity Framework.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder TryAdd<TService,TImplementation> (Func<IServiceProvider,TImplementation> factory) where TService : class where TImplementation : class, TService;
abstract member TryAdd : Func<IServiceProvider, #'Service> -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder (requires 'Service : null)
override this.TryAdd : Func<IServiceProvider, #'Service> -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder (requires 'Service : null)
Public Overridable Function TryAdd(Of TService As Class, TImplementation As Class) (factory As Func(Of IServiceProvider, TImplementation)) As EntityFrameworkServicesBuilder

Type Parameters

TService

The contract for the service.

TImplementation

The concrete type that implements the service.

Parameters

factory
Func<IServiceProvider,TImplementation>

The factory that will create the service instance.

Returns

This builder, such that further calls can be chained.

Remarks

See Implementation of database providers and extensions for more information and examples.

Applies to

TryAdd<TService>(Func<IServiceProvider,TService>)

Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs

Adds a factory for an Entity Framework service only if one has not already been registered. The scope of the service is automatically defined by Entity Framework.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder TryAdd<TService> (Func<IServiceProvider,TService> factory) where TService : class;
abstract member TryAdd : Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder (requires 'Service : null)
override this.TryAdd : Func<IServiceProvider, 'Service (requires 'Service : null)> -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder (requires 'Service : null)
Public Overridable Function TryAdd(Of TService As Class) (factory As Func(Of IServiceProvider, TService)) As EntityFrameworkServicesBuilder

Type Parameters

TService

The contract for the service.

Parameters

factory
Func<IServiceProvider,TService>

The factory that will create the service instance.

Returns

This builder, such that further calls can be chained.

Remarks

See Implementation of database providers and extensions for more information and examples.

Applies to

TryAdd<TService>(TService)

Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs
Source:
EntityFrameworkServicesBuilder.cs

Adds an implementation of an Entity Framework service only if one has not already been registered. This method can only be used for singleton services.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder TryAdd<TService> (TService implementation) where TService : class;
abstract member TryAdd : 'Service -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder (requires 'Service : null)
override this.TryAdd : 'Service -> Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder (requires 'Service : null)
Public Overridable Function TryAdd(Of TService As Class) (implementation As TService) As EntityFrameworkServicesBuilder

Type Parameters

TService

The contract for the service.

Parameters

implementation
TService

The implementation of the service.

Returns

This builder, such that further calls can be chained.

Remarks

See Implementation of database providers and extensions for more information and examples.

Applies to