From 98375f8629d6e73eb07b211b83b58b8ff5b29924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Fri, 20 Jan 2023 17:04:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0sqlsugar=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Filters/SqlsugarDataFiter.cs | 13 +++++++++++-- .../Yi.Framework.Data/YiFrameworkDataModule.cs | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Filters/SqlsugarDataFiter.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Filters/SqlsugarDataFiter.cs index 9ab2b055..f3ee5479 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Filters/SqlsugarDataFiter.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Core.Sqlsugar/Filters/SqlsugarDataFiter.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; @@ -10,18 +11,25 @@ namespace Yi.Framework.Core.Sqlsugar.Filters { public class SqlsugarDataFiter : IDataFilter { + private ISqlSugarClient _Db { get; set; } + public SqlsugarDataFiter(ISqlSugarClient sqlSugarClient) + { + _Db = sqlSugarClient; + } public void AddFilter(Expression> expression) where TFilter : class { - throw new NotImplementedException(); + _Db.QueryFilter.AddTableFilter(expression); } public IDisposable Disable() where TFilter : class { + _Db.QueryFilter.ClearAndBackup(); throw new NotImplementedException(); } public IDisposable Enable() where TFilter : class { + _Db.QueryFilter.Restore(); throw new NotImplementedException(); } @@ -32,6 +40,7 @@ namespace Yi.Framework.Core.Sqlsugar.Filters public void RemoveFilter() where TFilter : class { + _Db.QueryFilter.Clear(); throw new NotImplementedException(); } } diff --git a/Yi.Framework.Net6/src/framework/Yi.Framework.Data/YiFrameworkDataModule.cs b/Yi.Framework.Net6/src/framework/Yi.Framework.Data/YiFrameworkDataModule.cs index e48fa9b0..cade1dae 100644 --- a/Yi.Framework.Net6/src/framework/Yi.Framework.Data/YiFrameworkDataModule.cs +++ b/Yi.Framework.Net6/src/framework/Yi.Framework.Data/YiFrameworkDataModule.cs @@ -6,11 +6,15 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Yi.Framework.Core.Attributes; using Yi.Framework.Data.Entities; using Yi.Framework.Data.Filters; +using Yi.Framework.Ddd; namespace Yi.Framework.Data { + [DependsOn( + typeof(YiFrameworkDddModule))] public class YiFrameworkDataModule : IStartupModule { public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context) @@ -25,6 +29,7 @@ namespace Yi.Framework.Data public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context) { + //添加默认没有真正实现的 services.AddTransient(); } }