Пример #1
0
 public List <City> cityWithPopulationBiggerThanMin(int min)
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         return(se.Cities.Where(c => c.Population > min).ToList());
     };
 }
Пример #2
0
 public List <City> GetAllCity()
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         return(se.Cities.ToList());
     };
 }
Пример #3
0
 public List <District> GetByIdDistrict(int id)
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         return(se.Districts.Where(c => c.ID == id).ToList());
     };
 }
Пример #4
0
 public List <City> GetByIdCity(int id)
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         return(se.Cities.Where(c => c.ID == id).ToList());
     };
 }
Пример #5
0
 public List <District> GetAllDistrict()
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         return(se.Districts.ToList());
     };
 }
Пример #6
0
 public void AddDistrict(District district)
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         se.Districts.Add(district);
         se.SaveChanges();
     };
 }
Пример #7
0
 public void AddCity(City city)
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         se.Cities.Add(city);
         se.SaveChanges();
     };
 }
Пример #8
0
 public List <City> GetAllCityQuerySyntax()
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         var results = from s in se.Cities
                       select s;
         return(results.ToList());
     };
 }
Пример #9
0
        public void DeleteDistrict(int id)
        {
            using (finalSQLEntities se = new finalSQLEntities())
            {
                se.Districts.Remove(se.Districts.First(_ => _.ID == id));

                se.SaveChanges();
            };
        }
Пример #10
0
 public void DeleteCityAll()
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         se.Database.ExecuteSqlCommand
             ($"delete from Cities ");
         se.SaveChanges();
     };
 }
Пример #11
0
 public void UpdateDistrict(int id, District district)
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         district.ID = id;
         se.Districts.AddOrUpdate(district);
         se.SaveChanges();
     };
 }
Пример #12
0
 public void UpdateCity(int id, City city)
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         city.ID = id;
         se.Cities.AddOrUpdate(city);
         se.SaveChanges();
     };
 }
Пример #13
0
 public void FillDistrictPopulation(int districtId)
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         int districtPopulation = se.Cities.Where(c => c.District.ID == districtId).Sum(c => c.Population).Value;
         se.Database.ExecuteSqlCommand
             ($"update [dbo].[Districts] set [Population]={districtPopulation} where [ID]={districtId}");
         se.SaveChanges();
     };
 }
Пример #14
0
 public void DeleteDistrictsAll()
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         se.Database.ExecuteSqlCommand
             ($"delete from [dbo].[Cities];" +
             $"delete from [dbo].[Districts]");
         se.SaveChanges();
     };
 }