Ejemplo n.º 1
0
        public IEnumerable<object> GetRaces(int page, int pageSize)
        {
            using (var data = new Formula1Context())
            {
                if (_lastpageSearched == page)
                    return _cache;
                _lastpageSearched = page;

                var q = (from r in data.Races
                         from rr in r.RaceResults
                         orderby r.Date ascending
                         select new
                         {
                             Year = r.Date.Year,
                             Country = r.Circuit.Country,
                             Position = rr.Position,
                             Racer = rr.Racer.FirstName + " " + rr.Racer.LastName,
                             Car = rr.Team.Name,
                             Points = rr.Points
                         }).Skip(page * pageSize).Take(pageSize);
                _cache = q.ToList();
                return _cache;
            }

        }
Ejemplo n.º 2
0
 private List<Championship> GetYears()
 {
     using (var data = new Formula1Context())
     {
         return data.Races.Select(r => new Championship
         {
             Year = r.Date.Year
         }).Distinct().OrderBy(c => c.Year).ToList();
     }
 }
 private IEnumerable<F1RaceResult> GetResults()
 {
     using (var context = new Formula1Context())
     {
         return (from rr in context.RaceResults
                 where rr.Race.Date == this.Date
                 select new F1RaceResult
                 {
                     Position = rr.Position,
                     Racer = rr.Racer.FirstName + " " + rr.Racer.LastName,
                     Car = rr.Team.Name
                 }).ToList();
     }
 }
 private IEnumerable<F1Race> GetRaces()
 {
     using (var context = new Formula1Context())
     {
         return (from r in context.Races
                 where r.Date.Year == Year
                 orderby r.Date
                 select new F1Race
                 {
                     Date = r.Date,
                     Country = r.Circuit.Country
                 }).ToList();
     }
 }
Ejemplo n.º 5
0
 private IEnumerable<object> GetRaces()
 {
     using (var data = new Formula1Context())
     {
         return (from r in data.Races
                 from rr in r.RaceResults
                 orderby r.Date ascending
                 select new
                 {
                     r.Date.Year,
                     r.Circuit.Country,
                     rr.Position,
                     Racer = rr.Racer.FirstName + " " + rr.Racer.LastName,
                     Car = rr.Team.Name
                 }).Skip(_currentPage * _pageSize).Take(_pageSize).ToList();
     }
 }