Return back DatabaseBackedStore's query and populate functions

This commit is contained in:
TocoToucan
2017-10-15 00:40:41 +03:00
parent 5f083f10a7
commit 7cf5d63cd3
10 changed files with 117 additions and 80 deletions

View File

@ -2,9 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
using osu.Game.Database;
@ -134,45 +132,5 @@ namespace osu.Game.Beatmaps
{
Connection.BeatmapSetInfo.RemoveRange(Connection.BeatmapSetInfo.Where(b => b.DeletePending && !b.Protected));
}
public BeatmapSetInfo QueryBeatmapSet(Func<BeatmapSetInfo, bool> query)
{
return Connection.BeatmapSetInfo
.Include(b => b.Metadata)
.Include(b => b.Beatmaps).ThenInclude(b => b.Ruleset)
.Include(b => b.Beatmaps).ThenInclude(b => b.Difficulty)
.Include(b => b.Files).ThenInclude(f => f.FileInfo)
.FirstOrDefault(query);
}
public List<BeatmapSetInfo> QueryBeatmapSets(Expression<Func<BeatmapSetInfo, bool>> query)
{
return Connection.BeatmapSetInfo
.Include(b => b.Metadata)
.Include(b => b.Beatmaps).ThenInclude(b => b.Ruleset)
.Include(b => b.Beatmaps).ThenInclude(b => b.Difficulty)
.Include(b => b.Files).ThenInclude(f => f.FileInfo)
.Where(query).ToList();
}
public BeatmapInfo QueryBeatmap(Func<BeatmapInfo, bool> query)
{
return Connection.BeatmapInfo
.Include(b => b.BeatmapSet)
.Include(b => b.Metadata)
.Include(b => b.Ruleset)
.Include(b => b.Difficulty)
.FirstOrDefault(query);
}
public List<BeatmapInfo> QueryBeatmaps(Expression<Func<BeatmapInfo, bool>> query)
{
return Connection.BeatmapInfo
.Include(b => b.BeatmapSet)
.Include(b => b.Metadata)
.Include(b => b.Ruleset)
.Include(b => b.Difficulty)
.Where(query).ToList();
}
}
}