Partager via


AccessorExtensions.GetService Méthode

Définition

Surcharges

GetService(IInfrastructure<IServiceProvider>, Type)

Résout un service à partir du IServiceProvider exposé à partir d’un type qui implémente IInfrastructure<T>.

GetService<TService>(IInfrastructure<IServiceProvider>)

Résout un service à partir du IServiceProvider exposé à partir d’un type qui implémente IInfrastructure<T>.

GetService(IInfrastructure<IServiceProvider>, Type)

Résout un service à partir du IServiceProvider exposé à partir d’un type qui implémente IInfrastructure<T>.

[System.Diagnostics.DebuggerStepThrough]
public static object GetService (this Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider> accessor, Type serviceType);
[<System.Diagnostics.DebuggerStepThrough>]
static member GetService : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider> * Type -> obj
<Extension()>
Public Function GetService (accessor As IInfrastructure(Of IServiceProvider), serviceType As Type) As Object

Paramètres

accessor
IInfrastructure<IServiceProvider>

Objet exposant le fournisseur de services.

serviceType
Type

Type de service à résoudre.

Retours

Service demandé.

Attributs

Remarques

IInfrastructure<T> est utilisé pour masquer les propriétés qui ne sont pas destinées à être utilisées dans le code d’application, mais qui peuvent être utilisées dans des méthodes d’extension écrites par des fournisseurs de base de données, etc.

Pour plus d’informations et d’exemples, consultez Accès aux services DbContext .

S’applique à

GetService<TService>(IInfrastructure<IServiceProvider>)

Résout un service à partir du IServiceProvider exposé à partir d’un type qui implémente IInfrastructure<T>.

public static TService GetService<TService> (this Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider> accessor);
[System.Diagnostics.DebuggerStepThrough]
public static TService GetService<TService> (this Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider> accessor);
[System.Diagnostics.DebuggerStepThrough]
public static TService GetService<TService> (this Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider> accessor) where TService : class;
static member GetService : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider> -> 'Service
[<System.Diagnostics.DebuggerStepThrough>]
static member GetService : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider> -> 'Service
[<System.Diagnostics.DebuggerStepThrough>]
static member GetService : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<IServiceProvider> -> 'Service (requires 'Service : null)
<Extension()>
Public Function GetService(Of TService) (accessor As IInfrastructure(Of IServiceProvider)) As TService
<Extension()>
Public Function GetService(Of TService As Class) (accessor As IInfrastructure(Of IServiceProvider)) As TService

Paramètres de type

TService

Type de service à résoudre.

Paramètres

accessor
IInfrastructure<IServiceProvider>

Objet exposant le fournisseur de services.

Retours

TService

Service demandé.

Attributs

Remarques

IInfrastructure<T> est utilisé pour masquer les propriétés qui ne sont pas destinées à être utilisées dans le code d’application, mais qui peuvent être utilisées dans des méthodes d’extension écrites par des fournisseurs de base de données, etc.

Pour plus d’informations et d’exemples, consultez Accès aux services DbContext .

S’applique à