public static Task<(int RowsAffected, int ReturnValue, IReadOnlyDictionary<string, Object> OutputValues)> ExecuteMethodNonQueryAsync(
this DbContext dataContext,
MethodInfo methodInfo,
Object?[] parameters,
CancellationToken cancellationToken = default
)<ExtensionAttribute>
Public Shared Function ExecuteMethodNonQueryAsync (
dataContext As DbContext,
methodInfo As MethodInfo,
parameters As Object(),
Optional cancellationToken As CancellationToken = Nothing
) As Task(Of (RowsAffected As Integer, ReturnValue As Integer, OutputValues As IReadOnlyDictionary(Of String, Object)))public:
[ExtensionAttribute]
static Task<ValueTuple<int, int, IReadOnlyDictionary<String^, Object^>^>>^ ExecuteMethodNonQueryAsync(
DbContext^ dataContext,
MethodInfo^ methodInfo,
array<Object^>^ parameters,
CancellationToken cancellationToken = CancellationToken()
)[<ExtensionAttribute>]
static member ExecuteMethodNonQueryAsync :
dataContext : DbContext *
methodInfo : MethodInfo *
parameters : Object[] *
?cancellationToken : CancellationToken
(* Defaults:
let _cancellationToken = defaultArg cancellationToken new CancellationToken()
*)
-> Task<ValueTuple<int, int, IReadOnlyDictionary<string, Object>>> The stored procedure name is determined by looking for the MethodStoredProcedureAttribute on the calling data context method. If not specified, the stored procedure name is assumed to be the same as the calling method's name. If the method name ends with the AsyncMethodSuffix value, the indicated suffix is removed from the method name to get the stored procedure name.
If the connection is not in an open state, it is opened temporarily while executing the stored procedure.
// The stored procedure names are inferred from the method names without the "Async" suffix.
// Execute a stored procedure and return its return value asynchronously
public async int spStockAddAsync(string symbol, string assetDescription,
decimal currentBid, decimal currentAsk, decimal priceChangePercent)
{
var result = await this.ExecuteMethodNonQueryAsync(this.GetMethodInfo(), [symbol,
assetDescription, currentBid, currentAsk, priceChangePercent]);
return result.ReturnValue;
}
// Execute a stored procedure and return the number of rows affected
public async int spStockDeleteAsync(string symbol)
{
var result = await this.ExecuteMethodNonQueryAsync(this.GetMethodInfo(), [symbol]);
return result.RowsAffected;
}
// Execute a stored procedure and return the output parameters via the ref parameters on
// the method. We can also return the stored procedure's return value or rows affected.
public async int spCheckForEmployeeScheduleAsync(string bidGroup, int entityKey,
ref bool bidGroupScheduled, ref bool entityScheduled)
{
var result = await this.ExecuteMethodNonQueryAsync(this.GetMethodInfo(), [bidGroup, entityKey,
bidGroupScheduled, entityScheduled]);
bidGroupScheduled = (bool)result.OutputValues[nameof(bidGroupScheduled);
entityScheduled = (bool)result.OutputValues[nameof(entityScheduled);
return result.ReturnValue;
}