retornar mas de un objeto
Publicado por sergio (45 intervenciones) el 14/04/2015 19:30:02
tengo el siguiente codigo y lo que necesito es retornar el objeto COLUMNAS que es u List y el objeto lstturnos,
me podrian decir como hacerlo
me podrian decir como hacerlo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
public static List<misturnos1> Listarturnos1()
{
SqlConnection objConexion = null;
try
{
objConexion = new SqlConnection(Conexiones.StringConexion);
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
String miFecha = "20150401";
SqlCommand objCommand = new SqlCommand("exec sp_turnos1 @paramusu", objConexion);
SqlParameter objusuario = new SqlParameter("@paramusu", miFecha);
objCommand.Parameters.Add(objusuario);
SqlDataReader objReader = null;
List<misturnos1> lstturnos = new List<misturnos1>();
try
{
objConexion.Open();
objReader=objCommand.ExecuteReader();
List<string> columnas = new List<string>();
for (int i = 0; i<objReader.FieldCount ; i++)
{
columnas.Add(objReader.GetName(i));
}
while (objReader.Read())
{
string Time = objReader.GetTimeSpan(0).ToString();
misturnos1 objturnos1 = new misturnos1(Convert.ToString(objReader.GetTimeSpan(0)),
objReader.IsDBNull(1) == true ? "" : objReader.GetString(1),
objReader.IsDBNull(2) == true ? "" : objReader.GetString(2),
objReader.IsDBNull(3) == true ? "" : objReader.GetString(3),
objReader.IsDBNull(4) == true ? "" : objReader.GetString(4),
objReader.IsDBNull(5) == true ? "" : objReader.GetString(5));
lstturnos.Add(objturnos1);
}
return lstturnos;
}
catch (SqlException ex)
{
foreach (SqlError sError in ex.Errors)
{
Func_proc.Erroressql(sError.Number);
}
return null;
}
finally
{
objConexion.Close();
}
}
Valora esta pregunta


0