using Furion; using Microsoft.Extensions.DependencyInjection; using Yi.Framework.Infrastructure.Sqlsugar.Uow; namespace Yi.Framework.Infrastructure.Sqlsugar { /// /// 这一块,需要做成上下文对象,会进行重构 /// public static class SqlsugarExtensions { /// /// 使用默认上下文 /// /// public static void AddDbSqlsugarContextServer(this IServiceCollection services) { services.AddDbSqlsugarOption(); services.AddSingleton(x => x.GetRequiredService().SqlSugarClient); services.AddSingleton(); } /// /// 自定义上下文 /// /// /// public static void AddDbSqlsugarContextServer(this IServiceCollection services) where DbContext : SqlSugarDbContext { services.AddDbSqlsugarOption(); services.AddSingleton(x => x.GetRequiredService().SqlSugarClient); services.AddSingleton(); } public static void AddDbSqlsugarOption(this IServiceCollection services) { services.Configure(App.Configuration.GetSection("DbConnOptions")); services.AddUnitOfWork(); } } }