diff --git a/osu.Game/Database/DatabaseBackedStore.cs b/osu.Game/Database/DatabaseBackedStore.cs index 04aa8f91ae..040b23a82e 100644 --- a/osu.Game/Database/DatabaseBackedStore.cs +++ b/osu.Game/Database/DatabaseBackedStore.cs @@ -18,6 +18,11 @@ namespace osu.Game.Database private readonly ThreadLocal queryContext; + /// + /// Refresh an instance potentially from a diffrent thread with a local context-tracked instance. + /// + protected void Refresh(ref T obj) where T : class, IHasPrimaryKey => obj = GetContext().Find(obj.ID); + /// /// Retrieve a shared context for performing lookups (or write operations on the update thread, for now). /// diff --git a/osu.Game/Database/IHasPrimaryKey.cs b/osu.Game/Database/IHasPrimaryKey.cs new file mode 100644 index 0000000000..9af9852b03 --- /dev/null +++ b/osu.Game/Database/IHasPrimaryKey.cs @@ -0,0 +1,10 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Database +{ + public interface IHasPrimaryKey + { + int ID { get; set; } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 8f519d8915..dc6cf7e300 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -282,6 +282,7 @@ + 20171019041408_InitialCreate.cs