- 修改 FreeSql.Repository Autofac 注入方式,真正的实现全局过滤功能;

- 增加 FreeSql.Repository DataFilter 属性;
```csharp
repos.DataFilter.Disable("test") 临时禁用,不影响全部;
repos.DataFilter.DisableAll()
repos.DataFilter.Enable("test")
repos.DataFilter.EnableAll()
repos.DataFilter.Apply("name", a => a.Id > 1) 附加新的过滤器
```
This commit is contained in:
28810
2019-03-12 16:33:10 +08:00
parent dae8eb7a67
commit acf6fa0391
12 changed files with 221 additions and 172 deletions

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Text;
using System.Linq.Expressions;
using System.Linq;
public static class FreeSqlRepositoryIFreeSqlExtenssions {
@ -44,7 +45,7 @@ public static class FreeSqlRepositoryIFreeSqlExtenssions {
static ConcurrentDictionary<Type, IRepository> dicGetGuidRepository = new ConcurrentDictionary<Type, IRepository>();
/// <summary>
/// 合并两个仓储的设置,以便查询
/// 合并两个仓储的设置(过滤+分表),以便查询
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <typeparam name="T2"></typeparam>
@ -52,6 +53,8 @@ public static class FreeSqlRepositoryIFreeSqlExtenssions {
/// <param name="repos"></param>
/// <returns></returns>
public static ISelect<TEntity> FromRepository<TEntity, T2>(this ISelect<TEntity> that, BaseRepository<T2> repos) where TEntity : class where T2 : class {
return that.AsTable(repos.AsTableSelectInternal).Where<T2>(repos.FilterInternal);
var filters = (repos.DataFilter as DataFilter<T2>)._filters.Where(a => a.Value.IsEnabled == true);
foreach (var filter in filters) that.Where<T2>(filter.Value.Expression);
return that.AsTable(repos.AsTableSelectInternal);
}
}