blob: 466c304f1129214d3db2458f30fe91d53f8b3b00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using MySql.Data.EntityFrameworkCore;
using Classes;
namespace Database {
public class DatabaseContext : DbContext {
public DatabaseContext() {
Details = Task.Run(async () => await DetailsHelper.GetDetails()).GetAwaiter().GetResult();
}
public DbSet<Article> Articles;
public DbSet<Config> Configs;
public Dictionary<string, string> Details;
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
optionsBuilder.UseMySQL($"server=localhost;uid={Details["username"]};password={Details["password"]};database=news_aggregator");
}
}
}
|