ExecutionStrategyExtensions.Execute Method

Definition

Overloads

Execute(IExecutionStrategy, Action)

Executes the specified operation.

Execute<TResult>(IExecutionStrategy, Func<TResult>)

Executes the specified operation and returns the result.

Execute<TState,TResult>(IExecutionStrategy, Func<TState,TResult>, TState)

Executes the specified operation and returns the result.

Execute<TState,TResult>(IExecutionStrategy, TState, Func<TState,TResult>)

Executes the specified operation and returns the result.

Execute<TState,TResult>(IExecutionStrategy, Func<TState,TResult>, Func<TState,ExecutionResult<TResult>>, TState)
Obsolete.

Executes the specified operation and returns the result.

Execute<TState,TResult>(IExecutionStrategy, TState, Func<TState,TResult>, Func<TState,ExecutionResult<TResult>>)

Executes the specified operation and returns the result.

Execute<TState>(IExecutionStrategy, Action<TState>, TState)

Executes the specified operation.

Execute<TState>(IExecutionStrategy, TState, Action<TState>)

Executes the specified operation.

Execute(IExecutionStrategy, Action)

Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs

Executes the specified operation.

C#
public static void Execute (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Action operation);

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Action

A delegate representing an executable operation that doesn't return any results.

Remarks

See Connection resiliency and database retries for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

Execute<TResult>(IExecutionStrategy, Func<TResult>)

Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs

Executes the specified operation and returns the result.

C#
public static TResult Execute<TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<TResult> operation);

Type Parameters

TResult

The return type of operation.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Func<TResult>

A delegate representing an executable operation that returns the result of type TResult.

Returns

TResult

The result from the operation.

Remarks

See Connection resiliency and database retries for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

Execute<TState,TResult>(IExecutionStrategy, Func<TState,TResult>, TState)

Executes the specified operation and returns the result.

C#
public static TResult Execute<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<TState,TResult> operation, TState state);

Type Parameters

TState

The type of the state.

TResult

The return type of operation.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Func<TState,TResult>

A delegate representing an executable operation that returns the result of type TResult.

state
TState

The state that will be passed to the operation.

Returns

TResult

The result from the operation.

Applies to

Entity Framework Core 1.1
Product Versions
Entity Framework Core 1.1

Execute<TState,TResult>(IExecutionStrategy, TState, Func<TState,TResult>)

Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs

Executes the specified operation and returns the result.

C#
public static TResult Execute<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, TState state, Func<TState,TResult> operation);

Type Parameters

TState

The type of the state.

TResult

The return type of operation.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

state
TState

The state that will be passed to the operation.

operation
Func<TState,TResult>

A delegate representing an executable operation that returns the result of type TResult.

Returns

TResult

The result from the operation.

Remarks

See Connection resiliency and database retries for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

Execute<TState,TResult>(IExecutionStrategy, Func<TState,TResult>, Func<TState,ExecutionResult<TResult>>, TState)

Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs

Caution

Use overload that takes the state first

Executes the specified operation and returns the result.

C#
public static TResult Execute<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<TState,TResult> operation, Func<TState,Microsoft.EntityFrameworkCore.Storage.ExecutionResult<TResult>> verifySucceeded, TState state);
C#
[System.Obsolete("Use overload that takes the state first")]
public static TResult Execute<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<TState,TResult> operation, Func<TState,Microsoft.EntityFrameworkCore.Storage.ExecutionResult<TResult>> verifySucceeded, TState state);

Type Parameters

TState

The type of the state.

TResult

The return type of operation.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Func<TState,TResult>

A delegate representing an executable operation that returns the result of type TResult.

verifySucceeded
Func<TState,ExecutionResult<TResult>>

A delegate that tests whether the operation succeeded even though an exception was thrown.

state
TState

The state that will be passed to the operation.

Returns

TResult

The result from the operation.

Attributes

Exceptions

The operation has not succeeded after the configured number of retries.

Applies to

Entity Framework Core 3.1 and other versions
Product Versions (Obsolete)
Entity Framework Core 2.0, 2.1, 2.2, 3.0 (3.1)

Execute<TState,TResult>(IExecutionStrategy, TState, Func<TState,TResult>, Func<TState,ExecutionResult<TResult>>)

Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs

Executes the specified operation and returns the result.

C#
public static TResult Execute<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, TState state, Func<TState,TResult> operation, Func<TState,Microsoft.EntityFrameworkCore.Storage.ExecutionResult<TResult>> verifySucceeded);
C#
public static TResult Execute<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, TState state, Func<TState,TResult> operation, Func<TState,Microsoft.EntityFrameworkCore.Storage.ExecutionResult<TResult>>? verifySucceeded);

Type Parameters

TState

The type of the state.

TResult

The return type of operation.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

state
TState

The state that will be passed to the operation.

operation
Func<TState,TResult>

A delegate representing an executable operation that returns the result of type TResult.

verifySucceeded
Func<TState,ExecutionResult<TResult>>

A delegate that tests whether the operation succeeded even though an exception was thrown.

Returns

TResult

The result from the operation.

Exceptions

The operation has not succeeded after the configured number of retries.

Remarks

See Connection resiliency and database retries for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

Execute<TState>(IExecutionStrategy, Action<TState>, TState)

Executes the specified operation.

C#
public static void Execute<TState> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Action<TState> operation, TState state);

Type Parameters

TState

The type of the state.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Action<TState>

A delegate representing an executable operation that doesn't return any results.

state
TState

The state that will be passed to the operation.

Applies to

Entity Framework Core 1.1
Product Versions
Entity Framework Core 1.1

Execute<TState>(IExecutionStrategy, TState, Action<TState>)

Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs
Source:
ExecutionStrategyExtensions.cs

Executes the specified operation.

C#
public static void Execute<TState> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, TState state, Action<TState> operation);

Type Parameters

TState

The type of the state.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

state
TState

The state that will be passed to the operation.

operation
Action<TState>

A delegate representing an executable operation that doesn't return any results.

Remarks

See Connection resiliency and database retries for more information and examples.

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0