|
- using Furion;
- using Microsoft.Extensions.DependencyInjection;
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPA.KitChen.GroupMealOrder.SqlSugar
- {
- public static class SqlsugarSetup
- {
- /// <summary>
- ///
- /// </summary>
- /// <param name="services"></param>
- public static void AddSqlsugarSetup(this IServiceCollection services)
- {
- //如果多个数数据库传 List<ConnectionConfig>
- var configConnection = new ConnectionConfig()
- {
- DbType = DbType.MySql,
- ConnectionString = App.Configuration["DBConnectionStr"],
- IsAutoCloseConnection = true
- };
- var sqlSugar = SqlSugarDb.SqlSugarScope(configConnection);
- services.AddSingleton<ISqlSugarClient>(sqlSugar);//这边是SqlSugarScope用AddSingleton
-
-
- //如果多个数数据库传 List<ConnectionConfig>
- var sqlSugarLog = SqlSugarDb.SqlSugarScopeLog(new ConnectionConfig()
- {
- DbType = DbType.MySql,
- ConnectionString = App.Configuration["DBConnectionLogStr"],
- IsAutoCloseConnection = true
- });
- services.AddSingleton<ISqlSugarClient>(sqlSugarLog);//这边是SqlSugarScope用AddSingleton
- }
- }
- }
|