aboutsummaryrefslogtreecommitdiff
path: root/Database
diff options
context:
space:
mode:
authorAryadev Chavali <aryadevchavali1@gmail.com>2019-02-04 12:27:17 +0000
committerAryadev Chavali <aryadevchavali1@gmail.com>2019-02-04 12:27:17 +0000
commit629a4cc2b86faed2732829faf5421f50a5a67b81 (patch)
tree92e91bac304b3baae1a2784e8dd4ca9b2e8f6ce6 /Database
parent4e729d1b0a9ca65eaaa8f95eeba216abc68c2447 (diff)
downloadnewsaggregator-629a4cc2b86faed2732829faf5421f50a5a67b81.tar.gz
newsaggregator-629a4cc2b86faed2732829faf5421f50a5a67b81.tar.bz2
newsaggregator-629a4cc2b86faed2732829faf5421f50a5a67b81.zip
Made a property for details and used it in OnConfiguring method
Diffstat (limited to 'Database')
-rw-r--r--Database/Database.cs15
1 files changed, 12 insertions, 3 deletions
diff --git a/Database/Database.cs b/Database/Database.cs
index f687efd..5bc33b7 100644
--- a/Database/Database.cs
+++ b/Database/Database.cs
@@ -1,15 +1,24 @@
using System;
-using Classes;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+
using Microsoft.EntityFrameworkCore;
using MySql.Data.EntityFrameworkCore;
+using Classes;
+
namespace Database {
- public class Database: DbContext {
+ public class Database : DbContext {
+ public Database() {
+ Details = Task.Run(async () => await DetailsHelper.GetDetails()).GetAwaiter().GetResult();
+ }
public DbSet<Article> Articles;
public DbSet<Config> Configs;
+ public static Dictionary<string, string> Details;
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
- // optionsBuilder.UseMySQL("server=localhost;uid")
+ optionsBuilder.UseMySQL($"server=localhost;uid={Details["username"]};password={Details["password"]};database=news_aggregator");
}
}
}