mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-17 00:37:54 +02:00
Load entry references and collections
This commit is contained in:
@ -40,6 +40,7 @@ public class RetrieveChaptersJob : Job
|
||||
|
||||
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
||||
{
|
||||
context.Entry(Manga).Collection<Chapter>(m => m.Chapters).Load();
|
||||
// This gets all chapters that are not downloaded
|
||||
Chapter[] allChapters = Manga.MangaConnector.GetChapters(Manga, Language).DistinctBy(c => c.ChapterId).ToArray();
|
||||
Chapter[] newChapters = allChapters.Where(chapter => Manga.Chapters.Contains(chapter) == false).ToArray();
|
||||
@ -47,7 +48,8 @@ public class RetrieveChaptersJob : Job
|
||||
|
||||
try
|
||||
{
|
||||
context.Chapters.AddRange(newChapters);
|
||||
foreach (Chapter newChapter in newChapters)
|
||||
Manga.Chapters.Add(newChapter);
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch (DbUpdateException e)
|
||||
|
Reference in New Issue
Block a user