我有以下运行大约 20 个 sql 查询的方法。将结果返回给客户的最佳方式是什么?
public int Results()
{
using (var conn = GetConnection())
using (var cmd = new SqlCommand())
{
cmd.Connection = conn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = @"SELECT TOP 1 stdent_number from Students";
conn.Open();
var result = (int)cmd.ExecuteScalar();
cmd.CommandText = @"SELECT TOP 1 class_number from Classes";
var number = (int)cmd.ExecuteScalar();
cmd.CommandText = @"SELECT TOP 1 table from Tables";
var table = (int)cmd.ExecuteScalar();
cmd.CommandText = @"SELECT TOP 1 suite from Suites";
var suite = (int)cmd.ExecuteScalar();
.....
//I want to return result, number, table and suite so they can be populated on client
//What is the best way to return? Should I create IEnumerable and add values to it and return
//as IEnumerable or should these be returned all separately or as a dictionary?
//Also this is just an example in real time I have at least 15 values from sql queries that I //want to return
}
}