示例#1
0
        public List <Huesped> FindAll()
        {
            string         cadenaFindAll  = "SELECT fecha_ini, fecha_fin FROM Reserva";
            List <Huesped> listaHuespedes = new List <Huesped>();

            using (SqlConnection cn = BdSQL.Conectar())
            {
                using (SqlCommand cmd = new SqlCommand(cadenaFindAll, cn))
                {
                    cn.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            Huesped unH = new Huesped();
                            unH.Load(reader);
                            if (unH.Validar())
                            {
                                listaHuespedes.Add(unH);
                            }
                        }
                    }
                }
            }
            return(listaHuespedes);
        }