see my code and below approach and guide me How to make the store procedure call routine generalize which will work in any scenario.
store procedure may have many input type params.
store procedure may have many output type params.
store procedure has return parameter
store procedure may return multiple resultset.
protected IEnumerable<T> ExecuteStoredProc(SqlCommand command, string CountColName="TotalCount")
{
var reader = (SqlDataReader)null;
var list = new List<T>();
try
{
command.Connection = _connection;
command.CommandType = CommandType.StoredProcedure;
_connection.Open();
reader = command.ExecuteReader();
while (reader.Read())
{
var record = PopulateRecord(reader);
if (record != null) list.Add(record);
}
reader.NextResult();
if (reader.HasRows)
{
while (reader.Read())
{
GetDataCount(Convert.ToInt32(reader[CountColName].ToString()));
}
}
}
finally
{
// Always call Close when done reading.
reader.Close();
_connection.Close();
_connection.Dispose();
}
return list;
}
}so please rectify my above routine as a result it should work for any scenario. thanks