1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:07:52 +08:00

Small DB-related refactoring

This commit is contained in:
TocoToucan 2017-10-09 23:30:32 +03:00
parent 41a90c8b11
commit ef417c6388
5 changed files with 4 additions and 10 deletions

View File

@ -27,14 +27,13 @@ namespace osu.Game.Beatmaps
public int BeatmapSetInfoId { get; set; }
[Required]
public BeatmapSetInfo BeatmapSet { get; set; }
public int? BeatmapMetadataId { get; set; }
public BeatmapMetadata Metadata { get; set; }
public int BeatmapDifficultyId { get; set; }
[Required]
public BeatmapDifficulty Difficulty { get; set; }
[NotMapped]

View File

@ -17,8 +17,6 @@ namespace osu.Game.Beatmaps
public BeatmapMetadata Metadata { get; set; }
public int BeatmapMetadataId { get; set; }
public List<BeatmapInfo> Beatmaps { get; set; }
[NotMapped]

View File

@ -20,11 +20,8 @@ namespace osu.Game.Database
this.connectionString = connectionString;
}
public DbSet<BeatmapMetadata> BeatmapMetadata { get; set; }
public DbSet<BeatmapDifficulty> BeatmapDifficulty { get; set; }
public DbSet<BeatmapInfo> BeatmapInfo { get; set; }
public DbSet<BeatmapSetInfo> BeatmapSetInfo { get; set; }
public DbSet<BeatmapSetFileInfo> BeatmapSetFileInfo { get; set; }
public DbSet<DatabasedKeyBinding> DatabasedKeyBinding { get; set; }
public DbSet<FileInfo> FileInfo { get; set; }
public DbSet<RulesetInfo> RulesetInfo { get; set; }

View File

@ -56,7 +56,7 @@ namespace osu.Game.IO
{
string hash = data.ComputeSHA2Hash();
var existing = Connection.FileInfo.Where(f => f.Hash == hash).FirstOrDefault();
var existing = Connection.FileInfo.FirstOrDefault(f => f.Hash == hash);
var info = existing ?? new FileInfo { Hash = hash };

View File

@ -60,7 +60,7 @@ namespace osu.Game.Rulesets
{
var us = createRulesetInfo(r);
var existing = Connection.RulesetInfo.Where(ri => ri.InstantiationInfo == us.InstantiationInfo).FirstOrDefault();
var existing = Connection.RulesetInfo.FirstOrDefault(ri => ri.InstantiationInfo == us.InstantiationInfo);
if (existing == null)
Connection.RulesetInfo.Add(us);