Fix relation Manga->Chapter (latest)

This commit is contained in:
Glax 2024-12-16 20:03:38 +01:00
parent 7f946da1c3
commit 1044821147
3 changed files with 14 additions and 15 deletions

View File

@ -18,7 +18,6 @@ public class Chapter : IComparable<Chapter>
public string ArchiveFileName { get; private set; }
public bool Downloaded { get; internal set; } = false;
[ForeignKey("MangaId")]
public Manga ParentManga { get; init; }
public Chapter(Manga parentManga, string url, float chapterNumber,

View File

@ -46,10 +46,13 @@ public class Manga(
public string FolderName { get; private set; } = BuildFolderName(name);
public float IgnoreChapterBefore { get; internal set; } = ignoreChapterBefore;
[ForeignKey("LatestChapterDownloadedId")]
public Chapter? LatestChapterDownloaded { get; private set; } = latestChapterDownloaded;
[ForeignKey("LatestChapterAvailableId")]
public Chapter? LatestChapterAvailable { get; private set; } = latestChapterAvailable;
[ForeignKey("MangaConnectorId")]
public MangaConnector MangaConnector { get; private set; } = mangaConnector;
[ForeignKey("AuthorIds")]

View File

@ -51,18 +51,6 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
.HasValue<DownloadSingleChapterJob>(JobType.DownloadSingleChapterJob)
.HasValue<UpdateMetadataJob>(JobType.UpdateMetaDataJob);
modelBuilder.Entity<Chapter>()
.HasOne<Manga>(c => c.ParentManga);
modelBuilder.Entity<Chapter>()
.Navigation(c => c.ParentManga)
.AutoInclude();
modelBuilder.Entity<Manga>()
.HasOne<Chapter>(m => m.LatestChapterAvailable)
.WithOne();
modelBuilder.Entity<Manga>()
.HasOne<Chapter>(m => m.LatestChapterDownloaded)
.WithOne();
modelBuilder.Entity<Manga>()
.HasOne<MangaConnector>(m => m.MangaConnector);
modelBuilder.Entity<Manga>()
@ -79,14 +67,23 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
.Navigation(m => m.Tags)
.AutoInclude();
modelBuilder.Entity<Manga>()
.HasMany<Link>(m => m.Links);
.HasMany<Link>(m => m.Links)
.WithOne();
modelBuilder.Entity<Manga>()
.Navigation(m => m.Links)
.AutoInclude();
modelBuilder.Entity<Manga>()
.HasMany<MangaAltTitle>(m => m.AltTitles);
.HasMany<MangaAltTitle>(m => m.AltTitles)
.WithOne();
modelBuilder.Entity<Manga>()
.Navigation(m => m.AltTitles)
.AutoInclude();
modelBuilder.Entity<Chapter>()
.HasOne<Manga>(c => c.ParentManga)
.WithMany();
modelBuilder.Entity<Chapter>()
.Navigation(c => c.ParentManga)
.AutoInclude();
}
}