aboutsummaryrefslogtreecommitdiff
path: root/Database/Database.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Database/Database.cs')
-rw-r--r--Database/Database.cs12
1 files 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<Config> Configs { get; set; }
public async Task<int> InsertArticles(IEnumerable<Article> 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) {