예제 #1
0
        static List <County> GenerateCounty(District district, int numbreOfCounty)
        {
            List <County> counties = new List <County>();

            for (int i = 1; i <= numbreOfCounty; i++)
            {
                var newCounty = new County();
                newCounty.Name     = "county" + i;
                newCounty.District = district;
                //newCounty.Cities = GenerateCity(newCounty,2);

                counties.Add(newCounty);
            }
            return(counties);
        }
예제 #2
0
        public static void FilterByCounty(County county)
        {
            using (var context = new ShopContext())
            {
                var shopList = from s in context.Shops
                               join c in context.City
                               on s.City.CityId equals c.CityId
                               join co in context.County
                               on c.County.CountyId equals co.CountyId
                               where co.CountyId == county.CountyId
                               select new { CountyName = co.Name, c.Name, s.ShopId, shopName = s.Name };

                foreach (var Shop in shopList)
                {
                    Console.WriteLine(Shop);
                }
            }
        }
예제 #3
0
        static List <City> GenerateCity(County county, int numbreOfCities)
        {
            List <City> cities = new List <City>();

            for (int i = 1; i <= numbreOfCities; i++)
            {
                var newCity = new City();
                newCity.Name   = "city" + i;
                newCity.County = county;
                Random random  = new Random();
                int    zipcode = random.Next(10000, 99999);
                newCity.ZipCode = zipcode;
                //newCity.Shops = GenerateShop(newCity, 1);

                cities.Add(newCity);
            }
            return(cities);
        }
예제 #4
0
        public static List <City> GetCityList(County county)
        {
            using (var context = new ShopContext())
            {
                List <City> cities = new List <City>();

                var citiesList = from c in context.City.AsEnumerable()
                                 where c.County.CountyId == county.CountyId
                                 select c;
                cities.AddRange(citiesList);

                /*foreach (var District in france.Districts)
                 * {
                 *  foreach (var County in District.Counties)
                 *  {
                 *      foreach (var city in County.Cities)
                 *      {
                 *          cities.Add(city);
                 *      }
                 *  }
                 * }*/
                return(cities);
            }
        }