I have 3 sprocs
named:
- RECEIVED
- NOTRECEIVED
- UPDATESTATUS
RECEIVED
and NOTRECEIVED
have the following params
@ProductNumber,
@ProductName
UPDATESTATUS
has:
@BatchNumber
I have gone ahead and created a method which I use to execute the sproc named UPDATESTATUS
. I want to make it flexible so I can call it for all of the sprocs regardless of the params and pass in the sproc name to the method.
The method is as follows:
public async Task<int> ExecuteSproc(SqlParameter[] sqlParameter)
{
int result = await db.Database.ExecuteSqlCommandAsync("exec UPDATESTATUS @BatchNumber", sqlParameter);
return result;
}
This is how I called method ExecuteSproc()
SqlParameter[] sqlParameter = new SqlParameter[]
{
new SqlParameter("@BatchNumber", System.Data.SqlDbType.NVarChar){ Value = batchNumber}
};
int count = await ExecuteSproc(sqlParameter);
Can some tell me how I would achieve this please. I look at this post but the answer suggest I have to specify the param names whereas I am trying to make it a little more generic