public Fabricante LoadObject(SqlDataReader reader) { Fabricante fabricante = new Fabricante(); fabricante.Id = (int)reader["id"]; fabricante.Nombre = reader["nombre"].ToString(); return fabricante; }
public Fabricante Fabricante_FindById(int id) { SqlCommand cmd = new SqlCommand("SANTI_EL_LIDER.Fabricante_FindById", db.Connection); cmd.CommandType = CommandType.StoredProcedure; //seteo los parametros que recibe el stored procedure cmd.Parameters.AddWithValue("@id", SqlDbType.Int).Value = id; // cmd.Parameters.AddWithValue("@nombre", SqlDbType.NVarChar).Value = null; //ejecuto la consulta y traigo el resultado SqlDataReader sdr = cmd.ExecuteReader(); Fabricante fabricante = new Fabricante(); while (sdr.Read()) { fabricante = LoadObject(sdr); } sdr.Close(); return fabricante; }