|
123456789101112131415161718192021222324252627282930313233343536373839 |
- 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.GroupMeal.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
-
- var sqlSugarLog = SqlSugarDb.SqlSugarScopeLog(new ConnectionConfig()
- {
- DbType = DbType.MySql,
- ConnectionString = App.Configuration["DBConnectionLogStr"],
- IsAutoCloseConnection = true
- });
- services.AddSingleton<ISqlSugarClient>(sqlSugarLog);//这边是SqlSugarScope用AddSingleton
- }
- }
- }
|