Table of Contents

Class QueryContext

Namespace
Microsoft.EntityFrameworkCore.Query
Assembly
Microsoft.EntityFrameworkCore.dll

The principal data structure used by a compiled query during execution.

This type is typically used by database providers (and other extensions). It is generally not used in application code.

public abstract class QueryContext : IParameterValues
Inheritance
QueryContext
Implements
Inherited Members

Remarks

Constructors

QueryContext(QueryContextDependencies)

Creates a new QueryContext instance.

This type is typically used by database providers (and other extensions). It is generally not used in application code.

protected QueryContext(QueryContextDependencies dependencies)

Parameters

dependencies QueryContextDependencies

The dependencies to use.

Properties

CancellationToken

The cancellation token to use while executing the query.

public virtual CancellationToken CancellationToken { get; set; }

Property Value

CancellationToken

CommandLogger

The command logger to use while executing the query.

public virtual IDiagnosticsLogger<DbLoggerCategory.Database.Command> CommandLogger { get; }

Property Value

IDiagnosticsLogger<DbLoggerCategory.Database.Command>

ConcurrencyDetector

The concurrency detector to use while executing the query.

public virtual IConcurrencyDetector ConcurrencyDetector { get; }

Property Value

IConcurrencyDetector

Context

The current DbContext in using while executing the query.

public virtual DbContext Context { get; }

Property Value

DbContext

Dependencies

Dependencies for this service.

protected virtual QueryContextDependencies Dependencies { get; }

Property Value

QueryContextDependencies

ExceptionDetector

The exception detector to use while executing the query.

public virtual IExceptionDetector ExceptionDetector { get; }

Property Value

IExceptionDetector

ExecutionStrategy

The execution strategy to use while executing the query.

public virtual IExecutionStrategy ExecutionStrategy { get; }

Property Value

IExecutionStrategy

ParameterValues

The parameter values to use while executing the query.

public virtual IReadOnlyDictionary<string, object?> ParameterValues { get; }

Property Value

IReadOnlyDictionary<string, object>

QueryLogger

The query logger to use while executing the query.

public virtual IDiagnosticsLogger<DbLoggerCategory.Query> QueryLogger { get; }

Property Value

IDiagnosticsLogger<DbLoggerCategory.Query>

Methods

AddParameter(string, object?)

Adds a parameter to ParameterValues for this query.

public virtual void AddParameter(string name, object? value)

Parameters

name string

The name.

value object

The value.

InitializeStateManager(bool)

Initializes the IStateManager to be used with this QueryContext.

public virtual void InitializeStateManager(bool standAlone = false)

Parameters

standAlone bool

Whether a stand-alone IStateManager should be created to perform identity resolution.

SetNavigationIsLoaded(object, INavigationBase)

Sets the navigation for given entity as loaded.

public virtual void SetNavigationIsLoaded(object entity, INavigationBase navigation)

Parameters

entity object

The entity instance.

navigation INavigationBase

The navigation property.

StartTracking(IEntityType, object, ValueBuffer)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

[EntityFrameworkInternal]
public virtual InternalEntityEntry StartTracking(IEntityType entityType, object entity, ValueBuffer valueBuffer)

Parameters

entityType IEntityType
entity object
valueBuffer ValueBuffer

Returns

InternalEntityEntry

TryGetEntry(IKey, object[], bool, out bool)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

[EntityFrameworkInternal]
public virtual InternalEntityEntry? TryGetEntry(IKey key, object[] keyValues, bool throwOnNullKey, out bool hasNullKey)

Parameters

key IKey
keyValues object[]
throwOnNullKey bool
hasNullKey bool

Returns

InternalEntityEntry