private void AddAnimalsToDB() { using (AnimalsEntities animalProxy = new AnimalsEntities()) { animalProxy.Animals.AddRange(myAnimals); animalProxy.SaveChanges(); } }
private void DeleteAllAnimals() { using (AnimalsEntities ae = new AnimalsEntities()) { ae.Database.ExecuteSqlCommand("Truncate Table [AnimalPath]"); ae.Database.ExecuteSqlCommand("Delete from Animal"); ae.Database.ExecuteSqlCommand("DBCC CHECKIDENT ('dbo.Animal', RESEED, -1);"); ae.SaveChanges(); } }
private void UpdateAllAnimalsLocation(List<Animal> inA) { Parallel.ForEach(inA, a => { using (AnimalsEntities ae = new AnimalsEntities()) { Animal CurrAnimal = ae.Animals.Find(a.ID); CurrAnimal.CurrLocation = a.Move_Values.End; CurrAnimal.Move_Values.Start = a.Move_Values.End; AnimalPath path = a.AnimalPaths.LastOrDefault(); CurrAnimal.AnimalPaths = a.AnimalPaths; ae.SaveChanges(); }// end using }//end foreach scope );//end foreach loop }