2019-03-01 01:25:21 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using osu.Framework.Platform;
|
|
|
|
|
|
|
|
namespace osu.Game.Database
|
|
|
|
{
|
2019-12-10 13:04:26 +00:00
|
|
|
public abstract class MutableDatabaseBackedStoreWithFileIncludes<T, TFileInfo> : MutableDatabaseBackedStore<T>
|
|
|
|
where T : class, IHasPrimaryKey, ISoftDelete, IHasFiles<TFileInfo>
|
|
|
|
where TFileInfo : INamedFileInfo
|
2019-03-01 01:25:21 +00:00
|
|
|
{
|
|
|
|
protected MutableDatabaseBackedStoreWithFileIncludes(IDatabaseContextFactory contextFactory, Storage storage = null)
|
|
|
|
: base(contextFactory, storage)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override IQueryable<T> AddIncludesForConsumption(IQueryable<T> query) =>
|
|
|
|
base.AddIncludesForConsumption(query)
|
|
|
|
.Include(s => s.Files).ThenInclude(f => f.FileInfo);
|
2019-03-01 01:47:45 +00:00
|
|
|
|
|
|
|
protected override IQueryable<T> AddIncludesForDeletion(IQueryable<T> query) =>
|
|
|
|
base.AddIncludesForDeletion(query)
|
|
|
|
.Include(s => s.Files); // don't include FileInfo. these are handled by the FileStore itself.
|
2019-03-01 01:25:21 +00:00
|
|
|
}
|
|
|
|
}
|