forked from anjoy8/Blog.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseDBConfig.cs
More file actions
23 lines (17 loc) · 858 Bytes
/
BaseDBConfig.cs
File metadata and controls
23 lines (17 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using Blog.Core.Common;
using Microsoft.Extensions.Configuration;
using System;
using System.IO;
using System.Linq;
namespace Blog.Core.Repository
{
public class BaseDBConfig
{
static string sqlServerConnection = Appsettings.app(new string[] { "AppSettings", "SqlServer", "SqlServerConnection" });//获取连接字符串
public static string ConnectionString = File.Exists(@"D:\my-file\dbCountPsw1.txt") ? File.ReadAllText(@"D:\my-file\dbCountPsw1.txt").Trim() : (!string.IsNullOrEmpty(sqlServerConnection) ? sqlServerConnection : "server=.;uid=sa;pwd=sa;database=WMBlogDB");
//正常格式是
//public static string ConnectionString = "server=.;uid=sa;pwd=sa;database=WMBlogDB";
//原谅我用配置文件的形式,因为我直接调用的是我的服务器账号和密码,安全起见
}
}