I'm trying to execute stored procedure. The stored procedure name is given dynamically. Basically it's for a reporting suite. When the user select the report name from the dropdown, it will pass the name of the sp to the action result which returns a set of data, I managed to get the results from the sp into the List dataList. Now I'm trying to get the column names to be added in the List dataList. Any help would be appreciated
var cmd = _ctx.Database.GetDbConnection().CreateCommand();
cmd.CommandText = uspName;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@inparam_Fromdate", DateTime.Now.AddDays(1));
cmd.Parameters.Add(new SqlParameter("@inparam_Todate", "DateTime.Now.AddDays(2)));
cmd.Connection.Open();
using (var reader = cmd.ExecuteReader())
{
List<string[]> dataList = new List<string[]>();
while (reader.Read())
{
string[] tempRow = new string[reader.FieldCount];
for (var i = 0; i < reader.FieldCount; i++)
{
tempRow[i] = Convert.ToString(reader.GetValue(i));
}
dataList.Add(tempRow);
}
}