mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Revert "Return back DatabaseBackedStore's query and populate functions"
This reverts commit 7cf5d63cd3
.
This commit is contained in:
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using osu.Framework.Logging;
|
||||
@ -50,46 +49,6 @@ namespace osu.Game.Database
|
||||
/// </summary>
|
||||
public void Reset() => Prepare(true);
|
||||
|
||||
public List<T> Query<T>(Func<T, bool> filter = null) where T : class
|
||||
{
|
||||
checkType(typeof(T));
|
||||
|
||||
var dbSet = Connection.GetType().GetProperties().Single(property => property.PropertyType == typeof(DbSet<T>)).GetValue(Connection) as DbSet<T>;
|
||||
var query = dbSet.ToList();
|
||||
|
||||
if (filter != null)
|
||||
query = query.Where(filter).ToList();
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query and populate results.
|
||||
/// </summary>
|
||||
/// <param name="filter">An filter to refine results.</param>
|
||||
/// <returns></returns>
|
||||
public List<T> QueryAndPopulate<T>(Func<T, bool> filter)
|
||||
where T : class, IPopulate
|
||||
{
|
||||
checkType(typeof(T));
|
||||
|
||||
var query = Query(filter);
|
||||
foreach (var item in query)
|
||||
Populate(item);
|
||||
return query;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populate a database-backed item.
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Populate(IPopulate item)
|
||||
{
|
||||
checkType(item.GetType());
|
||||
|
||||
item.Populate(Connection);
|
||||
}
|
||||
|
||||
private void checkType(Type type)
|
||||
{
|
||||
if (!ValidTypes.Contains(type))
|
||||
|
Reference in New Issue
Block a user