示例#1
0
 public IEnumerable <planet> GetPilots()
 {
     using (StarwarsDBContext dbcontext = new StarwarsDBContext())
     {
         return(dbcontext.planets.ToList());
     }
 }
示例#2
0
        public opening_crawl GetLongestCrawl()

        {
            opening_crawl openingCrawlLongest = new opening_crawl();
            string        longest             = "";

            using (StarwarsDBContext dbContext = new StarwarsDBContext())
            {
                var Films = dbContext.films;

                foreach (film f in Films)
                {
                    if (f.opening_crawl.Length > longest.Length)
                    {
                        longest = f.opening_crawl;
                        openingCrawlLongest.openingCrawl = f.title.ToString();
                    }
                }
            }
            return(openingCrawlLongest);
        }
示例#3
0
        public Species GetSpecies()
        {
            Species species = new Species();

            using (StarwarsDBContext dbContext = new StarwarsDBContext())
            {
                List <string> listSpecies = new List <string>();
                List <film>   filmList    = dbContext.films.ToList();
                foreach (film f in filmList)
                {
                    foreach (species s in f.species)
                    {
                        foreach (person p in s.people)
                        {
                            listSpecies.Add(s.name);
                        }
                    }
                }
                species.speciesName = listSpecies.GroupBy(i => i).OrderByDescending(g => g.Count()).Take(2).Select(g => string.Format(g.Key + "({0})", g.Count()));
                return(species);
            }
        }
示例#4
0
        public CharName GetChars()
        {
            List <string> charactersList = new List <string>();
            CharName      character      = new CharName();

            using (StarwarsDBContext dbContext = new StarwarsDBContext())
            {
                List <person> Characters = dbContext.people.ToList();
                foreach (person p in Characters)
                {
                    foreach (film f in p.films)
                    {
                        charactersList.Add(p.name);
                    }
                }
                var characters = charactersList.GroupBy(i => i).OrderByDescending(g => g.Count()).Take(1).Select(g => g.Key);
                foreach (string charName in characters)
                {
                    character.charName = charName;
                }
                return(character);
            }
        }