Click or drag to resize

DbContextDoInExistingConnectionT Method (DbContextActionWithResultT, SqlConnection)

This will execute an action and return the result. While the action executes, Connection will be set to connectionToUse. If a current connection exists, it will be temporarily replaced by connectionToUse.

Namespace:  Omada.OE.AppLogic
Assembly:  Omada.OE.AppLogic (in Omada.OE.AppLogic.dll) Version: 15.0.0.0
Syntax
C#
public static T DoInExistingConnection<T>(
	DbContextActionWithResult<T> action,
	SqlConnection connectionToUse
)

Parameters

action
Type: Omada.OE.AppLogicDbContextActionWithResultT
The action to execute
connectionToUse
Type: System.Data.SqlClientSqlConnection
The connection to use

Type Parameters

T
The return type of the action

Return Value

Type: T
The result of the action
Examples
This will temporarily set DbContext.Connection to myDbConnection while calling someMethodUsingDbContextConnection. Normally, it is not necessary to specify the type parameter, since the compiler can infer it.
int count = DbContext.DoInExistingConnection( delegate { return someMethodUsingDbContextConnection(); }, myDbConnection);
See Also