2
3 - 将AppSettings从DMS.Infrastructure移至DMS.Application
4 - 将DatabaseSettings重命名为AppSettings.Database并更新所有引用
5 - 将配置文件从appSettings.json更改为dms_config.json
6 - 更新所有项目引用以使用新的AppSettings命名空间
7 - 移除DI容器中的SqlSugarDbContext直接实例化
8 - 添加Material Design Icons字体并更新设置视图UI
9 - 通过移除不必要的变量映射更新来优化S7服务
10 - 将数据库连接字符串属性名从Database更新为DbName
29 lines
723 B
C#
29 lines
723 B
C#
using DMS.Application.Configurations;
|
|
using SqlSugar;
|
|
|
|
namespace DMS.Infrastructure.Data;
|
|
|
|
public class SqlSugarDbContext
|
|
{
|
|
private readonly AppSettings _settings;
|
|
|
|
public SqlSugarDbContext(AppSettings settings)
|
|
{
|
|
_settings = settings;
|
|
}
|
|
|
|
|
|
public SqlSugarClient GetInstance()
|
|
{
|
|
var connectionString = _settings.ToConnectionString();
|
|
var dbType = (SqlSugar.DbType)Enum.Parse(typeof(SqlSugar.DbType), _settings.Db.DbType);
|
|
|
|
return new SqlSugarClient(new ConnectionConfig
|
|
{
|
|
ConnectionString = connectionString,
|
|
DbType = dbType,
|
|
IsAutoCloseConnection = true,
|
|
InitKeyType = InitKeyType.Attribute
|
|
});
|
|
}
|
|
} |