File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
framework/src/Bing.Datas.EntityFramework Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 77
88 <ItemGroup >
99 <Folder Include =" Bing\Data\Stores\EntityFrameworkCore\" />
10+ <Folder Include =" Bing\Data\Filters\" />
1011 </ItemGroup >
1112
1213 <ItemGroup >
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Linq . Expressions ;
3+
4+ namespace Bing . Data . Filters
5+ {
6+ /// <summary>
7+ /// 数据过滤器基类
8+ /// </summary>
9+ /// <typeparam name="TFilterType">过滤器类型</typeparam>
10+ public abstract class FilterBase < TFilterType > : IFilter < TFilterType > where TFilterType : class
11+ {
12+ /// <summary>
13+ /// 过滤器是否启用
14+ /// </summary>
15+ public bool IsEnabled { get ; private set ; } = true ;
16+
17+ /// <summary>
18+ /// 实体是否启用过滤器
19+ /// </summary>
20+ /// <typeparam name="TEntity">实体类型</typeparam>
21+ public bool IsEntityEnabled < TEntity > ( ) => typeof ( TFilterType ) . IsAssignableFrom ( typeof ( TEntity ) ) ;
22+
23+ /// <summary>
24+ /// 启用
25+ /// </summary>
26+ public void Enable ( ) => IsEnabled = true ;
27+
28+ /// <summary>
29+ /// 禁用
30+ /// </summary>
31+ public IDisposable Disable ( )
32+ {
33+ if ( IsEnabled == false )
34+ return new DisposeAction ( null ) ;
35+ IsEnabled = false ;
36+ return new DisposeAction ( Enable ) ;
37+ }
38+
39+ /// <summary>
40+ /// 获取过滤表达式
41+ /// </summary>
42+ /// <typeparam name="TEntity">实体类型</typeparam>
43+ public abstract Expression < Func < TEntity , bool > > GetExpression < TEntity > ( ) where TEntity : class ;
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments