aboutsummaryrefslogtreecommitdiff
path: root/Main
diff options
context:
space:
mode:
authorAryadev Chavali <aryadevchavali1@gmail.com>2019-02-10 15:00:24 +0000
committerAryadev Chavali <aryadevchavali1@gmail.com>2019-02-10 15:00:24 +0000
commit9ed58b9d5d3babef95be122d12eda3239c43a738 (patch)
treef50e4c880e0e1e6b1d83466be99108a1dcce3e73 /Main
parent2df5564dd52fb7ad5f2cbcd873a2d01fbf859616 (diff)
downloadnewsaggregator-9ed58b9d5d3babef95be122d12eda3239c43a738.tar.gz
newsaggregator-9ed58b9d5d3babef95be122d12eda3239c43a738.tar.bz2
newsaggregator-9ed58b9d5d3babef95be122d12eda3239c43a738.zip
Tested adding a range of articles with duplicate titles
Diffstat (limited to 'Main')
-rw-r--r--Main/Program.cs24
1 files changed, 21 insertions, 3 deletions
diff --git a/Main/Program.cs b/Main/Program.cs
index 4ad64af..0e88199 100644
--- a/Main/Program.cs
+++ b/Main/Program.cs
@@ -50,10 +50,28 @@ namespace Main {
private static async Task Main(string[] args) {
using (var db = new DatabaseContext()) {
+ int start;
try {
- await db.Articles.AddAsync(new Article() {
- Title = "TITLE"
- });
+ start = db.Articles.Last().ArticleID;
+ }
+ catch (Exception) {
+ start = 0;
+ }
+ try {
+ var articles = new List<Article>() {
+ new Article() {
+ Title = "TITLE1"
+ },
+ new Article() {
+ Title = "TITLE2"
+ },
+ new Article() {
+ Title = "TITLE3"
+ }
+ };
+ await db.AddRangeAsync(articles.Select((article, index) => new Article() {
+ ArticleID = index + start,
+ Title = article.Title}));
await db.SaveChangesAsync();
}
catch (Microsoft.EntityFrameworkCore.DbUpdateException) {