Tidy up some linq.

This commit is contained in:
Dean Herbert 2016-11-22 17:21:42 +09:00
parent a251db804c
commit 2ba365657e

View File

@ -136,7 +136,7 @@ namespace osu.Game.Database
public BeatmapSetInfo GetBeatmapSet(int id) public BeatmapSetInfo GetBeatmapSet(int id)
{ {
return Query<BeatmapSetInfo>().Where(s => s.BeatmapSetID == id).FirstOrDefault(); return Query<BeatmapSetInfo>().FirstOrDefault(s => s.BeatmapSetID == id);
} }
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null) public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null)
@ -175,10 +175,10 @@ namespace osu.Game.Database
return connection.GetWithChildren<T>(id); return connection.GetWithChildren<T>(id);
} }
public List<T> GetAllWithChildren<T>(Expression<Func<T, bool>> filter = null, public List<T> GetAllWithChildren<T>(Expression<Func<T, bool>> filter = null, bool recursive = true)
bool recursive = true) where T : class where T : class
{ {
return connection.GetAllWithChildren<T>(filter, recursive); return connection.GetAllWithChildren(filter, recursive);
} }
public T GetChildren<T>(T item, bool recursive = true) public T GetChildren<T>(T item, bool recursive = true)
@ -199,7 +199,7 @@ namespace osu.Game.Database
public void Update<T>(T record, bool cascade = true) where T : class public void Update<T>(T record, bool cascade = true) where T : class
{ {
if (!validTypes.Any(t => t == typeof(T))) if (validTypes.All(t => t != typeof(T)))
throw new ArgumentException(nameof(T), "Must be a type managed by BeatmapDatabase"); throw new ArgumentException(nameof(T), "Must be a type managed by BeatmapDatabase");
if (cascade) if (cascade)
connection.UpdateWithChildren(record); connection.UpdateWithChildren(record);