using Aucma.Scada.Api.Config;
using Aucma.Scada.Api.Repository.service;
using Aucma.Scada.Api.Repository.service.Impl;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace Aucma.Scada.Api.Repository
{
public static class SqlsugarSetup
{
///
/// 注册SqlSugar
///
///
public static void AddSqlSugarSetup(this IServiceCollection services)
{
services.AddSingleton(x =>
{
var appConfig = x.GetService();
SqlSugarScope Db = new SqlSugarScope(new List()
{
new ConnectionConfig()
{
ConfigId = "mes",
DbType = DbType.SqlServer,
ConnectionString = appConfig.mesConnStr,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
},
new ConnectionConfig()
{
ConfigId = "scada",
DbType = DbType.Oracle,
ConnectionString = appConfig.mcsConnStr,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
}
},
db =>
{
db.Aop.OnLogExecuting = (sql, pars) => { };
});
return Db;
});
}
///
/// 注册Repository、Service服务
///
///
public static void AddServices(this IServiceCollection services)
{
services.AddSingleton(typeof(Repository<>));
services.AddSingleton();
services.AddSingleton();
}
}
}