using Microsoft.Extensions.DependencyInjection; using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DAL { public static class DB { public static ISqlSugarClient SqlSugarClient { get; set; } public static void AddSqlSugarSetup(this IServiceCollection services, SqlSugar.DbType dataType, string conn) { if (services == null) throw new ArgumentNullException(nameof(services)); services.AddSingleton(s => { SqlSugarClient = new SqlSugarScope(new ConnectionConfig() { DbType = dataType, ConnectionString = conn, IsAutoCloseConnection = true }); return SqlSugarClient; }); } } }