使用sqlsugar内置工作单元

This commit is contained in:
chenchun
2023-01-02 13:59:05 +08:00
parent 0e78857645
commit ea35871aba
16 changed files with 65 additions and 58 deletions

View File

@@ -10,7 +10,6 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Common.Attribute;
using Yi.Framework.Uow.Interceptors;
namespace Yi.Framework.WebCore.AspNetCoreExtensions
{

View File

@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SqlSugar;
using System;
@@ -8,6 +9,7 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Common.Models;
using Yi.Framework.Repository;
using Yi.Framework.WebCore.CommonExtend;
namespace Yi.Framework.WebCore.AspNetCoreExtensions
@@ -124,6 +126,9 @@ namespace Yi.Framework.WebCore.AspNetCoreExtensions
});
services.AddSingleton<ISqlSugarClient>(sqlSugar);//这边是SqlSugarScope用AddSingleton
//添加工作单元
services.AddSingleton<ISugarUnitOfWork<UnitOfWork>>(new SugarUnitOfWork<UnitOfWork>(sqlSugar));
}
}

View File

@@ -15,7 +15,6 @@ using Yi.Framework.Interface;
using Yi.Framework.Job;
using Yi.Framework.Repository;
using Yi.Framework.Service;
using Yi.Framework.Uow.Interceptors;
using Yi.Framework.WebCore.AutoFacExtend;
using Module = Autofac.Module;
@@ -49,9 +48,9 @@ namespace Yi.Framework.WebCore.AutoFacExtend
containerBuilder.RegisterAssemblyTypes(assemblysServices)
.AsImplementedInterfaces()
.InstancePerLifetimeScope()
.EnableInterfaceInterceptors()
.EnableInterfaceInterceptors();
//开启工作单元拦截
.InterceptedBy(typeof(UnitOfWorkInterceptor));
//.InterceptedBy(typeof(UnitOfWorkInterceptor));
///反射注册任务调度层
var assemblysJob = GetDll("Yi.Framework.Job.dll");

View File

@@ -34,7 +34,6 @@
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
<ProjectReference Include="..\Yi.Framework.Service\Yi.Framework.Service.csproj" />
<ProjectReference Include="..\Yi.Framework.Uow\Yi.Framework.Uow.csproj" />
</ItemGroup>
<ItemGroup>