public static void UpdateGeographyKoord(int idUpdate, int srid, int radiusAction, decimal heighSeaLevel, string description, string typeKoordinates, params double[] latitude_longitude) { var context = new FastWaterContext(); //Объект класса для получения доступа к сущностям DbGeography geographyKoords = null; switch (typeKoordinates) { case "POINT": geographyKoords = CreatePoint(latitude_longitude[0], latitude_longitude[1]); break; case "LINESTRING": geographyKoords = CreateLineString(latitude_longitude[0], latitude_longitude[1], latitude_longitude[2], latitude_longitude[3]); break; case "POLYGON": geographyKoords = CreatePoligon(latitude_longitude); break; // case MessageBox.Show("Не верный тип координат"); } IQueryable <GeographicalKoordinate> query = context.GeographicalKoordinates; var updateObject = query.FirstOrDefault(x => x.Id_GeographicalKoordinates == idUpdate); updateObject.Koordinate = geographyKoords; updateObject.SRID = srid; updateObject.RadiusAction = radiusAction; updateObject.HeighSeaLevel = heighSeaLevel; updateObject.description = description; updateObject.TypeKoordinates = typeKoordinates; context.Entry(updateObject).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public static void AddPostToDataBase(string namePost, decimal distanceSensors, int IdKoords, string nameBasin, string nameGround, string nameLocality, string description) { using (var dbContext = new FastWaterContext()) { GeographicalKoordinate koordinate = GeographyKordinatesService.GetGeographicalKoordinatesEf().FirstOrDefault(y => y.Id_GeographicalKoordinates == IdKoords); Basin basin = dbContext.Basins.FirstOrDefault(y => y.NameBasin.Equals(nameBasin)); Ground ground = dbContext.Grounds.FirstOrDefault(y => y.TypeGround.Equals(nameGround)); Locality locality = dbContext.Localities.FirstOrDefault(y => y.NameLocality.Equals(nameLocality)); int idKoords = dbContext.GeographicalKoordinates.FirstOrDefault(x => x.Id_GeographicalKoordinates == IdKoords).Id_GeographicalKoordinates; int idbasin = dbContext.Basins.FirstOrDefault(y => y.NameBasin.Equals(nameBasin)).Id_Basin; int idGround = dbContext.Grounds.FirstOrDefault(y => y.TypeGround.Equals(nameGround)).Id_Ground; int idlocal = dbContext.Localities.FirstOrDefault(y => y.NameLocality.Equals(nameLocality)).Id_Locality; Post post = new Post() { NamePost = namePost, DistanceBeetwenSensors = distanceSensors, // GeographicalKoordinate = koordinate, Id_GeographicalKoordinates = idKoords, // Basin = basin, Id_Basin = idbasin, // Ground = ground, Id_Ground = idGround, // Locality = locality, Id_Locality = idlocal, description = description }; dbContext.Posts.Add(post); dbContext.SaveChanges(); } }
public static List <AVGSpeedLevelSnow> GetAvgSpeedLevelSnowEf() { var context = new FastWaterContext(); //Объект класса для получения доступа к сущностям IQueryable <AVGSpeedLevelSnow> query = context.AVGSpeedLevelSnows; //Формирование запроса к БД //(никаких даннных в БД ещё не идет //и ни каких данныч мы оттуда ещё не получили) List <AVGSpeedLevelSnow> listSpeedLevelWater = query.ToList(); //Формирование SQL-запроса, получение данных return(listSpeedLevelWater); }
public static List <Flood> GetFloodEf() { var context = new FastWaterContext(); //Объект класса для получения доступа к сущностям IQueryable <Flood> query = context.Floods; //Формирование запроса к БД //(никаких даннных в БД ещё не идет //и ни каких данныч мы оттуда ещё не получили) List <Flood> listFloods = query.ToList(); //Формирование SQL-запроса, получение данных return(listFloods); }
public static List <GeographicalKoordinate> GetGeographicalKoordinatesEf() { var context = new FastWaterContext(); //Объект класса для получения доступа к сущностям IQueryable <GeographicalKoordinate> query = context.GeographicalKoordinates; //Формирование запроса к БД //(никаких даннных в БД ещё не идет //и ни каких данныч мы оттуда ещё не получили) List <GeographicalKoordinate> listKoordinates = query.ToList(); //Формирование SQL-запроса, получение данных return(listKoordinates); }
public static List <ALLInformationOnPost> GetALLInformationOnPostEf() { var context = new FastWaterContext(); //Объект класса для получения доступа к сущностям IQueryable <ALLInformationOnPost> query = context.ALLInformationOnPosts; //Формирование запроса к БД //(никаких даннных в БД ещё не идет //и ни каких данныч мы оттуда ещё не получили) List <ALLInformationOnPost> listALLInformationOnPost = query.ToList(); //Формирование SQL-запроса, получение данных return(listALLInformationOnPost); }
public static void RemovePostEf(int idRemove) { var context = new FastWaterContext(); IQueryable <Post> query = context.Posts; var removeObject = query.Where(x => x.Id_Post == idRemove).FirstOrDefault(); if (removeObject != null) { context.Posts.Remove(removeObject); context.SaveChanges(); } }
public static void RemoveGeographicalKoordinatesEf(int idRemove) { var context = new FastWaterContext(); IQueryable <GeographicalKoordinate> query = context.GeographicalKoordinates; var removeObject = query.Where(x => x.Id_GeographicalKoordinates == idRemove).FirstOrDefault(); if (removeObject != null) { context.GeographicalKoordinates.Remove(removeObject); context.SaveChanges(); } }
public static void UpdatePost(int idUpdate, string namePost, decimal distanceSensors, int IdKoords, string nameBasin, string nameGround, string nameLocality, string description) { var context = new FastWaterContext(); //Объект класса для получения доступа к сущностям GeographicalKoordinate koordinate = GeographyKordinatesService.GetGeographicalKoordinatesEf().FirstOrDefault(y => y.Id_GeographicalKoordinates == IdKoords); Basin basin = context.Basins.FirstOrDefault(y => y.NameBasin.Equals(nameBasin)); Ground ground = context.Grounds.FirstOrDefault(y => y.TypeGround.Equals(nameGround)); Locality locality = context.Localities.FirstOrDefault(y => y.NameLocality.Equals(nameLocality)); IQueryable <Post> query = context.Posts; var updateObject = query.FirstOrDefault(x => x.Id_Post == idUpdate); updateObject.NamePost = namePost; updateObject.DistanceBeetwenSensors = distanceSensors; updateObject.GeographicalKoordinate = koordinate; updateObject.Basin = basin; updateObject.Ground = ground; updateObject.Locality = locality; updateObject.description = description; context.Entry(updateObject).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
public static void AddWeightParameterSnow(int id_WeightParameterSnow, int id_Post, int countInputs, int countLayer, int numberLayer, int countNeuron, decimal?longitudeDayStart, decimal?longitudeDayFinish, decimal?weightLongitudeDay, decimal?weightSnow, decimal?weightRain, decimal?weightSnowRain, decimal?weightAirHumidity, decimal?weightLevelSnow, decimal?weightChangeLevelSnowBefore, decimal?weightHardnessSnow, decimal?weightTemperatureDay, decimal?weightTemperatureNight, decimal?weightSolarActivity, decimal?weightLevelFreezingGround) { var context = new FastWaterContext(); Post post = context.Posts.FirstOrDefault(y => y.Id_Post == id_Post); WeightParameterSnow weightParameterSnow = new WeightParameterSnow { Id_WeightParameterSnow = id_WeightParameterSnow, Id_Post = id_Post, Post = post, CountInputs = countInputs, CountLayer = countLayer, NumberLayer = numberLayer, CountNeuron = countNeuron, LongitudeDayStart = longitudeDayStart, LongitudeDayFinish = longitudeDayFinish, WeightLongitudeDay = weightLongitudeDay, WeightSnow = weightSnow, WeightRain = weightRain, WeightSnowRain = weightSnowRain, WeightAirHumidity = weightAirHumidity, WeightLevelSnow = weightLevelSnow, WeightChangeLevelSnowBefore = weightChangeLevelSnowBefore, WeightHardnessSnow = weightHardnessSnow, WeightTemperatureDay = weightTemperatureDay, WeightTemperatureNight = weightTemperatureNight, WeightSolarActivity = weightSolarActivity, WeightLevelFreezingGround = weightLevelFreezingGround, }; context.WeightParameterSnows.Add(weightParameterSnow); context.SaveChanges(); }
public static List <FloodJoin> GetFloodСonnectionEF() { var context = new FastWaterContext(); var transaction = from flood in context.Floods join posts in context.Posts on flood.Id_Post equals posts.Id_Post into floodPost from postJoined in floodPost.DefaultIfEmpty() join postKoords in context.GeographicalKoordinates on postJoined.Id_GeographicalKoordinates equals postKoords.Id_GeographicalKoordinates into floodPostKoord from postKoordsJoined in floodPostKoord.DefaultIfEmpty() join posts in context.SolarActivities on flood.Id_SolarActivity equals posts.Id_SolarActivity into floodSolar from solarJoined in floodSolar.DefaultIfEmpty() select new FloodJoin { Id_flood = flood.Id_Flood, NamePost = postJoined.NamePost, Koords = postKoordsJoined.KoordinateText, Date = flood.DateAndTimes, LongitudeDay = flood.LongitudeDay, Snow = flood.Snow, Rain = flood.Rain, SnowRain = flood.SnowRain, AirHumidity = flood.AirHumidity, LevelSnow = flood.LevelSnow, HardnessSnow = flood.HardnessSnow, TemperatureDay = flood.TemperatureDay, TemperatureNight = flood.TemperatureNight, Id_SolarActivity = solarJoined.LevelSolar, LevelFreezingGround = flood.LevelFreezingGround, TemperatureWater = flood.TemperatureWater, LevelWater = flood.LevelWater, WarningFlood = flood.WarningFlood, }; List <FloodJoin> floodPlus = transaction.ToList(); return(floodPlus); }
public static void AddGeographyKoordToDataBase(int srid, int radiusAction, decimal heighSeaLevel, string description, string typeKoordinates, params double[] latitude_longitude) { var context = new FastWaterContext(); //var location = new GeographicalKoordinate() //{ // // Create a point using native DbGeography Factory method // Koordinate = DbGeography.PointFromText( // string.Format("POINT({0} {1})", -121.527200, 45.712113) // , 4326), //}; //context.GeographicalKoordinates.Add(location); DbGeography geographyKoords = null; switch (typeKoordinates) { case "POINT": geographyKoords = CreatePoint(latitude_longitude[0], latitude_longitude[1]); break; case "LINESTRING": geographyKoords = CreateLineString(latitude_longitude[0], latitude_longitude[1], latitude_longitude[2], latitude_longitude[3]); break; case "POLYGON": geographyKoords = CreatePoligon(latitude_longitude); break; // case MessageBox.Show("Не верный тип координат"); } GeographicalKoordinate geographicalKoordinate = new GeographicalKoordinate() { Koordinate = geographyKoords, SRID = srid, RadiusAction = radiusAction, HeighSeaLevel = heighSeaLevel, description = description, TypeKoordinates = typeKoordinates }; context.GeographicalKoordinates.Add(geographicalKoordinate); context.SaveChanges(); }