private void DeleteCountry(int id)
 {
     using (WpContext context = new WpContext(connStr))
     {
         if (!context.DatabaseExists())
         {
             context.CreateDatabase();
         }
         IQueryable <Country> query = from c in context.Countrys where c.CountryID == id select c;
         Country count = query.FirstOrDefault();
         context.Countrys.DeleteOnSubmit(count);
         context.SubmitChanges();
     }
 }
 private void CreateDatabase(string name)
 {
     using (WpContext context = new WpContext(connStr))
     {
         if (!context.DatabaseExists())
         {
             context.CreateDatabase();
         }
         Country model = new Country {
             CountryName = name
         };
         context.Countrys.InsertOnSubmit(model);
         context.SubmitChanges();
     }
 }
 private void SearchCountry(string name = "")
 {
     using (WpContext context = new WpContext(connStr))
     {
         if (!context.DatabaseExists())
         {
             context.CreateDatabase();
         }
         IQueryable <Country> query;
         if (!string.IsNullOrEmpty(name))
         {
             query = from c in context.Countrys where c.CountryName.Contains(name) select c;
         }
         else
         {
             query = from c in context.Countrys select c;
         }
         List <Country> list = query.ToList <Country>();
         listBox1.ItemsSource = list;
     }
 }