From 29fcd210aa0f2168613088f6d2a44cda060822dc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 22 Oct 2017 16:17:40 +0900 Subject: [PATCH] Centralise transaction committing --- osu.Game/Beatmaps/BeatmapManager.cs | 6 ++---- osu.Game/Database/OsuDbContext.cs | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 47dbc72837..b81e239015 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -198,7 +198,7 @@ namespace osu.Game.Beatmaps context.SaveChanges(); } - transaction.Commit(); + context.SaveChanges(transaction); return set; } } @@ -313,9 +313,7 @@ namespace osu.Game.Beatmaps } context.ChangeTracker.AutoDetectChangesEnabled = true; - context.SaveChanges(); - - transaction.Commit(); + context.SaveChanges(transaction); } } } diff --git a/osu.Game/Database/OsuDbContext.cs b/osu.Game/Database/OsuDbContext.cs index c509093cf9..99e5fa9741 100644 --- a/osu.Game/Database/OsuDbContext.cs +++ b/osu.Game/Database/OsuDbContext.cs @@ -93,6 +93,13 @@ namespace osu.Game.Database modelBuilder.Entity().HasOne(b => b.BaseDifficulty); } + public new int SaveChanges(IDbContextTransaction transaction = null) + { + var ret = base.SaveChanges(); + transaction?.Commit(); + return ret; + } + private class OsuDbLoggerFactory : ILoggerFactory { #region Disposal