コード例 #1
0
        public List <Chamado> Listar()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["bancodedados"].ConnectionString;

            List <Chamado> lst = new List <Chamado>();

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                using (SqlCommand comando = new SqlCommand())
                {
                    comando.Connection = conn;
                    conn.Open();
                    comando.CommandType = System.Data.CommandType.Text;
                    comando.CommandText = "select * from tb_chamados";

                    SqlDataReader reader = comando.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

                    lst = Chamado.PopularLista(reader);
                }
            }
            return(lst);
        }