private void ShowFromDBButton_Click(object sender, EventArgs e) { CountryData.Rows.Clear(); List <Country> countries; try { using (CountriesDBContext dBContext = new CountriesDBContext()) { var CountriesToShow = dBContext.Countries.ToList(); foreach (Country country in CountriesToShow) { CountryData.Rows.Add(country.Name, country.Code.ToString(), country.CapitalNavigation.Name, country.Area.ToString(), country.Population.ToString(), country.RegionNavigation.Name); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка"); } }
public CountryData(Dictionary <string, object> json) { dBContext = new CountriesDBContext(); region = Region.FromJson(json); city = City.FromJson(json); country = Country.FromJson(json, city, region); }