实现sqlsugar过滤器
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
@@ -10,18 +11,25 @@ namespace Yi.Framework.Core.Sqlsugar.Filters
|
|||||||
{
|
{
|
||||||
public class SqlsugarDataFiter : IDataFilter
|
public class SqlsugarDataFiter : IDataFilter
|
||||||
{
|
{
|
||||||
|
private ISqlSugarClient _Db { get; set; }
|
||||||
|
public SqlsugarDataFiter(ISqlSugarClient sqlSugarClient)
|
||||||
|
{
|
||||||
|
_Db = sqlSugarClient;
|
||||||
|
}
|
||||||
public void AddFilter<TFilter>(Expression<Func<TFilter, bool>> expression) where TFilter : class
|
public void AddFilter<TFilter>(Expression<Func<TFilter, bool>> expression) where TFilter : class
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_Db.QueryFilter.AddTableFilter<TFilter>(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDisposable Disable<TFilter>() where TFilter : class
|
public IDisposable Disable<TFilter>() where TFilter : class
|
||||||
{
|
{
|
||||||
|
_Db.QueryFilter.ClearAndBackup<TFilter>();
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDisposable Enable<TFilter>() where TFilter : class
|
public IDisposable Enable<TFilter>() where TFilter : class
|
||||||
{
|
{
|
||||||
|
_Db.QueryFilter.Restore();
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +40,7 @@ namespace Yi.Framework.Core.Sqlsugar.Filters
|
|||||||
|
|
||||||
public void RemoveFilter<TFilter>() where TFilter : class
|
public void RemoveFilter<TFilter>() where TFilter : class
|
||||||
{
|
{
|
||||||
|
_Db.QueryFilter.Clear<TFilter>();
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,15 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Core.Attributes;
|
||||||
using Yi.Framework.Data.Entities;
|
using Yi.Framework.Data.Entities;
|
||||||
using Yi.Framework.Data.Filters;
|
using Yi.Framework.Data.Filters;
|
||||||
|
using Yi.Framework.Ddd;
|
||||||
|
|
||||||
namespace Yi.Framework.Data
|
namespace Yi.Framework.Data
|
||||||
{
|
{
|
||||||
|
[DependsOn(
|
||||||
|
typeof(YiFrameworkDddModule))]
|
||||||
public class YiFrameworkDataModule : IStartupModule
|
public class YiFrameworkDataModule : IStartupModule
|
||||||
{
|
{
|
||||||
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
|
||||||
@@ -25,6 +29,7 @@ namespace Yi.Framework.Data
|
|||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||||
{
|
{
|
||||||
|
//添加默认没有真正实现的
|
||||||
services.AddTransient<IDataFilter, DefaultDataFilter>();
|
services.AddTransient<IDataFilter, DefaultDataFilter>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user