public static (int RowsAffected, int ReturnValue, IReadOnlyDictionary<string, Object> OutputValues) ExecuteMethodNonQuery(
this DbContext dataContext,
MethodInfo methodInfo,
params Object?[] parameters
)<ExtensionAttribute>
Public Shared Function ExecuteMethodNonQuery (
dataContext As DbContext,
methodInfo As MethodInfo,
ParamArray parameters As Object()
) As (RowsAffected As Integer, ReturnValue As Integer, OutputValues As IReadOnlyDictionary(Of String, Object))public:
[ExtensionAttribute]
static ValueTuple<int, int, IReadOnlyDictionary<String^, Object^>^> ExecuteMethodNonQuery(
DbContext^ dataContext,
MethodInfo^ methodInfo,
... array<Object^>^ parameters
)[<ExtensionAttribute>]
static member ExecuteMethodNonQuery :
dataContext : DbContext *
methodInfo : MethodInfo *
parameters : Object[] -> 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 connection is not in an open state, it is opened temporarily while executing the stored procedure.
// Execute a stored procedure and return its return value
public int spStockAdd(string symbol, string assetDescription, decimal currentBid,
decimal currentAsk, decimal priceChangePercent)
{
return this.ExecuteMethodNonQuery(this.GetMethodInfo(), symbol, assetDescription,
currentBid, currentAsk, priceChangePercent).ReturnValue;
}
// Execute a stored procedure and return the number of rows affected
public int spStockDelete(string symbol)
{
return this.ExecuteMethodNonQuery(this.GetMethodInfo(), symbol).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 int spCheckForEmployeeSchedule(string bidGroup, int entityKey,
ref bool bidGroupScheduled, ref bool entityScheduled)
{
var result = this.ExecuteMethodNonQuery(this.GetMethodInfo(), bidGroup, entityKey,
bidGroupScheduled, entityScheduled);
bidGroupScheduled = (bool)result.OutputValues[nameof(bidGroupScheduled);
entityScheduled = (bool)result.OutputValues[nameof(entityScheduled);
return result.ReturnValue;
}