From 6ca611ea71f7201dd9f5c2a685e5d5ad16e62ca1 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sun, 10 Feb 2019 17:44:35 +0000 Subject: Changed updater - try to get as many articles into the database --- Database/Database.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Database/Database.cs b/Database/Database.cs index 6c3511c..2e362af 100644 --- a/Database/Database.cs +++ b/Database/Database.cs @@ -24,12 +24,14 @@ namespace Database { public virtual DbSet Configs { get; set; } public async Task InsertArticles(IEnumerable
articles) { - try { - await Articles.AddRangeAsync(articles); - return await SaveChangesAsync(); - } catch (Microsoft.EntityFrameworkCore.DbUpdateException) { - return 0; // duplicate title id's + foreach (Article article in articles) { + try { + await Articles.AddAsync(article); + } catch (Microsoft.EntityFrameworkCore.DbUpdateException) { + continue; + } } + return await SaveChangesAsync(); } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { -- cgit v1.2.3-13-gbd6f