using Dapper; using Ewide.EntityFramework.Core.SqlSugar; using Furion; using Furion.DatabaseAccessor; using Microsoft.Extensions.DependencyInjection; using SqlSugar; using System.Collections.Generic; using System.Diagnostics; using System.Linq; namespace Ewide.EntityFramework.Core { public class Startup : AppStartup { public void ConfigureServices(IServiceCollection services) { services.AddDatabaseAccessor(options => { options.CustomizeMultiTenants(); // 自定义租户 options.AddDb(); //options.AddDb(); }, "Ewide.Database.Migrations"); // 注册dapper, 目前只能强行写死连接字符串和数据库程序集 services.AddDapper(App.Configuration["DefaultConnection"], SqlProvider.MySql); //sqlsugar的注册代码放到了SqlSugar文件夹里 services.AddSqlsugarSetup(); //List connectConfigList = new() //{ // new ConnectionConfig // { // ConnectionString = App.Configuration["SqlServerConnectionString:DefaultConnection"], // DbType = DbType.SqlServer, // IsAutoCloseConnection = true, // InitKeyType = InitKeyType.Attribute, // ConfigId = "0", // AopEvents = new AopEvents // { // OnLogExecuting = (sql, pars) => // { // Debugger.Log(1, "", "=============================== SqlSugar log started ===============================\r\n"); // Debugger.Log(2, "语句:", sql); // Debugger.Log(3, "参数:", string.Join(",", pars?.Select(it => it.ParameterName + ":" + it.Value))); // Debugger.Log(4, "", "=============================== SqlSugar log end ===============================\r\n"); // } // } // }, // new ConnectionConfig // { // ConnectionString = App.Configuration["ConnectionStrings:RoadflowConnection"], // DbType = DbType.MySql, // IsAutoCloseConnection = true, // InitKeyType = InitKeyType.Attribute, // ConfigId = "RoadFlowDB", // AopEvents = new AopEvents // { // OnLogExecuting = (sql, pars) => // { // Debugger.Log(1, "", "=============================== Roadflow SqlSugar log started ===============================\r\n"); // Debugger.Log(2, "语句:", sql); // Debugger.Log(3, "参数:", string.Join(",", pars?.Select(it => it.ParameterName + ":" + it.Value))); // Debugger.Log(4, "", "=============================== SqlSugar log end ===============================\r\n"); // }, // } // } //}; //services.AddSqlSugar(connectConfigList.ToArray()); } } }