#region << 版 本 注 释 >> /*-------------------------------------------------------------------- * 版权所有 (c) 2025 WenJY 保留所有权利。 * CLR版本:4.0.30319.42000 * 机器名称:Mr.Wen's MacBook Pro * 命名空间:Sln.Rfid.Repository * 唯一标识:065386F2-A6FA-475A-A7C3-E360F4125A1D * * 创建者:WenJY * 电子邮箱: * 创建时间:2025-11-25 14:03:48 * 版本:V1.0.0 * 描述: * *-------------------------------------------------------------------- * 修改人: * 时间: * 修改说明: * * 版本:V1.0.0 *--------------------------------------------------------------------*/ #endregion << 版 本 注 释 >> using System.Collections.Generic; using Microsoft.Extensions.DependencyInjection; using Sln.Rfid.Config; using SqlSugar; namespace Sln.Rfid.Repository { public static class SqlsugarSetup { /// /// 注册SqlSugar /// /// public static void AddSqlSugarSetup(this IServiceCollection services) { services.AddSingleton(x => { var appConfig = x.GetService(); var connectConfigList = new List(); if (appConfig.sqlConfig != null) { foreach (var item in appConfig.sqlConfig) { if (item.isFlag) { var config = new ConnectionConfig() { ConfigId = item.configId, DbType = (DbType)item.dbType, ConnectionString = item.connStr, InitKeyType = InitKeyType.Attribute, IsAutoCloseConnection = true, }; connectConfigList.Add(config); } } } SqlSugarScope Db = new SqlSugarScope(connectConfigList, db => { db.Aop.OnLogExecuting = (sql, pars) => { }; }); return Db; }); } } }