mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 修改 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:
@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user