Class GlobalFilter
Inheritance
System.Object
GlobalFilter
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: FreeSql.Internal
Assembly: FreeSql.dll
Syntax
public class GlobalFilter
Methods
| Improve this Doc View SourceApply<TEntity>(String, Expression<Func<TEntity, Boolean>>, Boolean)
创建一个过滤器
提示:在 Lambda 中判断登陆身份,请参考资料 AsyncLocal
Declaration
public GlobalFilter Apply<TEntity>(string name, Expression<Func<TEntity, bool>> where, bool before = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | 名字 |
| System.Linq.Expressions.Expression<System.Func<TEntity, System.Boolean>> | where | 表达式 |
| System.Boolean | before | 条件在最前面 |
Returns
| Type | Description |
|---|---|
| GlobalFilter |
Type Parameters
| Name | Description |
|---|---|
| TEntity |
ApplyIf<TEntity>(String, Func<Boolean>, Expression<Func<TEntity, Boolean>>, Boolean)
创建一个动态过滤器,当 condition 返回值为 true 时才生效
场景:当登陆身份是管理员,则过滤条件不生效
提示:在 Lambda 中判断登陆身份,请参考资料 AsyncLocal
Declaration
public GlobalFilter ApplyIf<TEntity>(string name, Func<bool> condition, Expression<Func<TEntity, bool>> where, bool before = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | 名字 |
| System.Func<System.Boolean> | condition | 委托,返回值为 true 时才生效 |
| System.Linq.Expressions.Expression<System.Func<TEntity, System.Boolean>> | where | 表达式 |
| System.Boolean | before | 条件在最前面 |
Returns
| Type | Description |
|---|---|
| GlobalFilter |
Type Parameters
| Name | Description |
|---|---|
| TEntity |
ApplyOnly<TEntity>(String, Expression<Func<TEntity, Boolean>>, Boolean)
创建一个过滤器(实体类型 属于指定 TEntity 才会生效)
提示:在 Lambda 中判断登陆身份,请参考资料 AsyncLocal
Declaration
public GlobalFilter ApplyOnly<TEntity>(string name, Expression<Func<TEntity, bool>> where, bool before = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | 名字 |
| System.Linq.Expressions.Expression<System.Func<TEntity, System.Boolean>> | where | 表达式 |
| System.Boolean | before | 条件在最前面 |
Returns
| Type | Description |
|---|---|
| GlobalFilter |
Type Parameters
| Name | Description |
|---|---|
| TEntity |
ApplyOnlyIf<TEntity>(String, Func<Boolean>, Expression<Func<TEntity, Boolean>>, Boolean)
创建一个过滤器(实体类型 属于指定 TEntity 才会生效)
场景:当登陆身份是管理员,则过滤条件不生效
提示:在 Lambda 中判断登陆身份,请参考资料 AsyncLocal
Declaration
public GlobalFilter ApplyOnlyIf<TEntity>(string name, Func<bool> condition, Expression<Func<TEntity, bool>> where, bool before = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | 名字 |
| System.Func<System.Boolean> | condition | 委托,返回值为 true 时才生效 |
| System.Linq.Expressions.Expression<System.Func<TEntity, System.Boolean>> | where | 表达式 |
| System.Boolean | before | 条件在最前面 |
Returns
| Type | Description |
|---|---|
| GlobalFilter |
Type Parameters
| Name | Description |
|---|---|
| TEntity |
GetAllFilters()
Declaration
public List<GlobalFilter.Item> GetAllFilters()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<GlobalFilter.Item> |
GetFilters()
Declaration
public List<GlobalFilter.Item> GetFilters()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<GlobalFilter.Item> |
Remove(String)
Declaration
public void Remove(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name |