Share via


AccessorExtensions.GetService Method

Definition

Overloads

GetService(IInfrastructure<IServiceProvider>, Type)

Resolves a service from the IServiceProvider exposed from a type that implements IInfrastructure<T>.

GetService<TService>(IInfrastructure<IServiceProvider>)

Resolves a service from the IServiceProvider exposed from a type that implements IInfrastructure<T>.

GetService(IInfrastructure<IServiceProvider>, Type)

Source:
AccessorExtensions.cs
Source:
AccessorExtensions.cs

Resolves a service from the IServiceProvider exposed from a type that implements 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

Parameters

accessor
IInfrastructure<IServiceProvider>

The object exposing the service provider.

serviceType
Type

The type of service to be resolved.

Returns

The requested service.

Attributes

Remarks

IInfrastructure<T> is used to hide properties that are not intended to be used in application code but can be used in extension methods written by database providers etc.

See Accessing DbContext services for more information and examples.

Applies to

GetService<TService>(IInfrastructure<IServiceProvider>)

Source:
AccessorExtensions.cs
Source:
AccessorExtensions.cs
Source:
AccessorExtensions.cs
Source:
AccessorExtensions.cs
Source:
AccessorExtensions.cs
Source:
AccessorExtensions.cs
Source:
AccessorExtensions.cs
Source:
AccessorExtensions.cs
Source:
AccessorExtensions.cs

Resolves a service from the IServiceProvider exposed from a type that implements 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

Type Parameters

TService

The type of service to be resolved.

Parameters

accessor
IInfrastructure<IServiceProvider>

The object exposing the service provider.

Returns

TService

The requested service.

Attributes

Remarks

IInfrastructure<T> is used to hide properties that are not intended to be used in application code but can be used in extension methods written by database providers etc.

See Accessing DbContext services for more information and examples.

Applies to