Fix cascading inserts.

This commit is contained in:
Dean Herbert 2016-10-21 17:01:12 +09:00 committed by Drew DeVault
parent 42f8d19c73
commit ee6c810df5
2 changed files with 22 additions and 11 deletions

View File

@ -10,18 +10,24 @@ namespace osu.Game.Database
public class BeatmapInfo public class BeatmapInfo
{ {
[PrimaryKey] [PrimaryKey]
public int BeatmapID { get; set; } public int BeatmapID { get; set; }
[ForeignKey(typeof(BeatmapSetInfo))] [ForeignKey(typeof(BeatmapSetInfo))]
public int BeatmapSetID { get; set; } public int BeatmapSetID { get; set; }
[ManyToOne] [ManyToOne]
public BeatmapSetInfo BeatmapSet { get; set; } public BeatmapSetInfo BeatmapSet { get; set; }
[ForeignKey(typeof(BeatmapMetadata))] [ForeignKey(typeof(BeatmapMetadata))]
public int BeatmapMetadataID { get; set; } public int BeatmapMetadataID { get; set; }
[OneToOne(CascadeOperations = CascadeOperation.All)]
public BeatmapMetadata Metadata { get; set; }
[ForeignKey(typeof(BaseDifficulty)), NotNull] [ForeignKey(typeof(BaseDifficulty)), NotNull]
public int BaseDifficultyID { get; set; } public int BaseDifficultyID { get; set; }
[OneToOne]
public BeatmapMetadata Metadata { get; set; } [OneToOne(CascadeOperations = CascadeOperation.All)]
[OneToOne]
public BaseDifficulty BaseDifficulty { get; set; } public BaseDifficulty BaseDifficulty { get; set; }
public string Path { get; set; } public string Path { get; set; }

View File

@ -8,14 +8,19 @@ namespace osu.Game.Database
public class BeatmapSetInfo public class BeatmapSetInfo
{ {
[PrimaryKey] [PrimaryKey]
public int BeatmapSetID { get; set; } public int BeatmapSetID { get; set; }
[OneToOne]
public BeatmapMetadata Metadata { get; set; } [OneToOne(CascadeOperations = CascadeOperation.All)]
[NotNull, ForeignKey(typeof(BeatmapMetadata))] public BeatmapMetadata Metadata { get; set; }
[NotNull, ForeignKey(typeof(BeatmapMetadata))]
public int BeatmapMetadataID { get; set; } public int BeatmapMetadataID { get; set; }
[OneToMany]
public List<BeatmapInfo> Beatmaps { get; set; } [OneToMany(CascadeOperations = CascadeOperation.All)]
public string Hash { get; set; } public List<BeatmapInfo> Beatmaps { get; set; }
public string Hash { get; set; }
public string Path { get; set; } public string Path { get; set; }
} }
} }