mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 15:27:20 +08:00
Allow "refreshing" instances via DatabaseBackedStore
This commit is contained in:
parent
5cd04392b4
commit
8452e315f4
@ -18,6 +18,11 @@ namespace osu.Game.Database
|
||||
|
||||
private readonly ThreadLocal<OsuDbContext> queryContext;
|
||||
|
||||
/// <summary>
|
||||
/// Refresh an instance potentially from a diffrent thread with a local context-tracked instance.
|
||||
/// </summary>
|
||||
protected void Refresh<T>(ref T obj) where T : class, IHasPrimaryKey => obj = GetContext().Find<T>(obj.ID);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a shared context for performing lookups (or write operations on the update thread, for now).
|
||||
/// </summary>
|
||||
|
10
osu.Game/Database/IHasPrimaryKey.cs
Normal file
10
osu.Game/Database/IHasPrimaryKey.cs
Normal file
@ -0,0 +1,10 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public interface IHasPrimaryKey
|
||||
{
|
||||
int ID { get; set; }
|
||||
}
|
||||
}
|
@ -282,6 +282,7 @@
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapSetCover.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapSetHeader.cs" />
|
||||
<Compile Include="Database\DatabaseContextFactory.cs" />
|
||||
<Compile Include="Database\IHasPrimaryKey.cs" />
|
||||
<Compile Include="Migrations\20171019041408_InitialCreate.cs" />
|
||||
<Compile Include="Migrations\20171019041408_InitialCreate.Designer.cs">
|
||||
<DependentUpon>20171019041408_InitialCreate.cs</DependentUpon>
|
||||
|
Loading…
x
Reference in New Issue
Block a user