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

                se.SaveChanges();
            };
        }
Ejemplo n.º 10
0
 public void DeleteCityAll()
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         se.Database.ExecuteSqlCommand
             ($"delete from Cities ");
         se.SaveChanges();
     };
 }
Ejemplo n.º 11
0
 public void UpdateDistrict(int id, District district)
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         district.ID = id;
         se.Districts.AddOrUpdate(district);
         se.SaveChanges();
     };
 }
Ejemplo n.º 12
0
 public void UpdateCity(int id, City city)
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         city.ID = id;
         se.Cities.AddOrUpdate(city);
         se.SaveChanges();
     };
 }
Ejemplo n.º 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();
     };
 }
Ejemplo n.º 14
0
 public void DeleteDistrictsAll()
 {
     using (finalSQLEntities se = new finalSQLEntities())
     {
         se.Database.ExecuteSqlCommand
             ($"delete from [dbo].[Cities];" +
             $"delete from [dbo].[Districts]");
         se.SaveChanges();
     };
 }