public void ClearDatabase() { #if MSSQL Categories.RemoveRange(Categories); RentalItems.RemoveRange(RentalItems); BookCopies.RemoveRange(BookCopies); Books.RemoveRange(Books); Rentals.RemoveRange(Rentals); Users.RemoveRange(Users); #else Categories.RemoveRange(Categories); BookCopies.RemoveRange(BookCopies .Include(nameof(BookCopy.RentalItems)) ); Books.RemoveRange(Books); Users.RemoveRange(Users .Include(nameof(User.Rentals)) ); #endif SaveChanges(); Reseed(nameof(Users)); Reseed(nameof(Books)); Reseed(nameof(BookCopies)); Reseed(nameof(Categories)); Reseed(nameof(Rentals)); Reseed(nameof(RentalItems)); }
public void ClearDatabase() { #if MSSQL Books.RemoveRange(Books); Users.RemoveRange(Users); BookCopies.RemoveRange(BookCopies); RentalItems.RemoveRange(RentalItems); Rentals.RemoveRange(Rentals); Categories.RemoveRange(Categories .Include(nameof(Category.Books)) ); #else Categories.RemoveRange(Categories .Include(nameof(Category.Books)) ); #endif SaveChanges(); /** * Décommenter la ligne suivante pour réinitialiser le compteur de clef autoincrementée */ Reseed(nameof(Users)); Reseed(nameof(Books)); Reseed(nameof(BookCopies)); Reseed(nameof(Categories)); Reseed(nameof(Rentals)); Reseed(nameof(RentalItems)); }
public void ClearDatabase() { #if MSSQL Console.WriteLine("qfklqsjdfkljqsdlfjiljsdfkljqsdkldfjklsqdjdhfjsqdhfjqsdhljkfklqsdjfklqsdjfkljsqddlkfjlsqdkjf"); RentalItems.RemoveRange(RentalItems); Rentals.RemoveRange(Rentals); Users.RemoveRange(Users); BookCopies.RemoveRange(BookCopies); Books.RemoveRange(Books); Categories.RemoveRange(Categories); #else #endif SaveChanges(); Reseed(nameof(Users)); Reseed(nameof(Books)); Reseed(nameof(Rentals)); Reseed(nameof(BookCopies)); Reseed(nameof(Categories)); Reseed(nameof(RentalItems)); /** * Décommenter la ligne suivante pour réinitialiser le compteur de clef autoincrementée */ //Reseed(nameof(Messages)); }
//------------------------ A Mettre à jour -------------------------------------------------------------------- !! public void ClearDatabase() { Users.RemoveRange(Users.Include(nameof(User.Rentals))); Rentals.RemoveRange(Rentals.Include(nameof(Rental.Items))); Books.RemoveRange(Books.Include(nameof(Book.Copies)).Include(nameof(Book.Categories))); Categories.RemoveRange(Categories.Include(nameof(Category.Books))); BookCopies.RemoveRange(BookCopies.Include(nameof(BookCopy.RentalItems))); RentalItems.RemoveRange(RentalItems); Reseed(nameof(Users)); Reseed(nameof(Rentals)); Reseed(nameof(Books)); Reseed(nameof(Categories)); Reseed(nameof(BookCopies)); Reseed(nameof(RentalItems)); this.SaveChanges(); }
public void ClearDatabase() { Users.RemoveRange(Users); Rentals.RemoveRange(Rentals); RentalItems.RemoveRange(RentalItems); BookCopies.RemoveRange(BookCopies); Books.RemoveRange(Books); Categories.RemoveRange(Categories); Reseed(nameof(Users)); Reseed(nameof(Books)); Reseed(nameof(Rentals)); Reseed(nameof(BookCopies)); Reseed(nameof(Categories)); Reseed(nameof(RentalItems)); SaveChanges(); }