Ejemplo n.º 1
0
        private List <Buyer> FillBuyerList()
        {
            Buyers.Clear();
            _dataSet.Clear();

            _command = "SELECT Id, Name FROM Buyers";
            _sqlDataAdapter.SelectCommand = new SqlCommand(_command, _sqlConnection);

            _sqlDataAdapter.Fill(_dataSet);

            Buyers = _dataSet.Tables[0].AsEnumerable().Select(dataRow =>
                                                              new Buyer
            {
                Id   = dataRow.Field <long>("Id"),
                Name = dataRow.Field <string>("Name")
            }).ToList();

            _dataSet.Clear();

            return(Buyers);
        }