Пример #1
0
        public List <CarRecord> GetCars(int page, int pageSize)
        {
            DbLayer db = new DbLayer();

            db.OpenConnection(ConnectionStr);
            DataTable dt = db.GetCars(page, pageSize);

            db.CloseConnection();

            List <CarRecord> ls = new List <CarRecord>();
            DataTableReader  rd = dt.CreateDataReader();

            while (rd.Read())
            {
                ls.Add(new CarRecord {
                    ID      = (int)rd["ID"],
                    Make    = (string)rd["Make"],
                    Model   = (string)rd["Model"],
                    Year    = (int)rd["Year"],
                    Doors   = (int)rd["Doors"],
                    Colours = (string)rd["Colour"],
                    Price   = (double)rd["Price"]
                });
            }

            return(ls);
        }