mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 12:28:15 +08:00
## v0.3.22
- 优化 导航属性 ManyToOne 名称查找规则; - 增加 IFreeSql.Aop 属性,未来所有拦截方法都在这里,第一期支持如下: * 监控 ToList 返回的的数据,用于拦截重新装饰; * 监视 Where,包括 select/update/delete,返回值 true 时可使上层不被执行; * 可自定义解析表达式; - 增加 ISelect.TractToList,用于单次跟踪或审核实体; - 优化 FreeSql.DbContext SaveChanges;
This commit is contained in:
@ -16,6 +16,13 @@ namespace FreeSql {
|
||||
/// <returns></returns>
|
||||
TSelect WithTransaction(DbTransaction transaction);
|
||||
|
||||
/// <summary>
|
||||
/// 审核或跟踪 ToList 即将返回的数据
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <returns></returns>
|
||||
TSelect TrackToList(Action<object> action);
|
||||
|
||||
/// <summary>
|
||||
/// 执行SQL查询,返回 DataTable
|
||||
/// </summary>
|
||||
|
@ -1,20 +1,64 @@
|
||||
//using FreeSql.DatabaseModel;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
using FreeSql.DatabaseModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
//namespace FreeSql {
|
||||
// public interface IAop {
|
||||
namespace FreeSql {
|
||||
public interface IAop {
|
||||
|
||||
// ISelect<T1> SelectFitler<T1>(ISelect<T1> select) where T1 : class;
|
||||
// //ISelect<T1, T2, T3> SelectFitler<T1, T2, T3>(ISelect<T1, T2, T3> select) where T1 : class where T2 : class where T3 : class;
|
||||
// //ISelect<T1, T2, T3, T4> SelectFitler<T1, T2, T3, T4>(ISelect<T1, T2, T3, T4> select) where T1 : class where T2 : class where T3 : class where T4 : class;
|
||||
// //ISelect<T1, T2, T3, T4, T5, T6> SelectFitler<T1, T2, T3, T4, T5, T6>(ISelect<T1, T2, T3, T4, T5, T6> select) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class;
|
||||
// //ISelect<T1, T2, T3, T4, T5, T6, T7> SelectFitler<T1, T2, T3, T4, T5, T6, T7>(ISelect<T1, T2, T3, T4, T5, T6, T7> select) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class;
|
||||
// //ISelect<T1, T2, T3, T4, T5, T6, T7, T8> SelectFitler<T1, T2, T3, T4, T5, T6, T7, T8>(ISelect<T1, T2, T3, T4, T5, T6, T7, T8> select) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class;
|
||||
// //ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> SelectFitler<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> select) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class;
|
||||
// //ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> SelectFitler<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> select) where T1 : class where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class;
|
||||
/// <summary>
|
||||
/// 监控 ToList 返回的的数据,用于拦截重新装饰
|
||||
/// </summary>
|
||||
EventHandler<AopToListEventArgs> ToList { get; set; }
|
||||
|
||||
// IUpdate<T1> UpdateFitler<T1>(IUpdate<T1> update) where T1 : class;
|
||||
// IDelete<T1> DeleteFitler<T1>(IUpdate<T1> delete) where T1 : class;
|
||||
// }
|
||||
//}
|
||||
/// <summary>
|
||||
/// 监视 Where,包括 select/update/delete,可控制使上层不被执行。
|
||||
/// </summary>
|
||||
EventHandler<AopWhereEventArgs> Where { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可自定义解析表达式
|
||||
/// </summary>
|
||||
EventHandler<AopParseExpressionEventArgs> ParseExpression { get; set; }
|
||||
}
|
||||
|
||||
public class AopToListEventArgs : EventArgs {
|
||||
public AopToListEventArgs(object list) {
|
||||
this.List = list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 可重新装饰的引用数据
|
||||
/// </summary>
|
||||
public object List { get; }
|
||||
}
|
||||
public class AopWhereEventArgs : EventArgs {
|
||||
public AopWhereEventArgs(params object[] parameters) {
|
||||
this.Parameters = parameters;
|
||||
}
|
||||
public object[] Parameters { get; }
|
||||
/// <summary>
|
||||
/// 可使上层不被执行这个条件
|
||||
/// </summary>
|
||||
public bool IsCancel { get; set; }
|
||||
}
|
||||
public class AopParseExpressionEventArgs : EventArgs {
|
||||
public AopParseExpressionEventArgs(Expression expression, Func<Expression, string> freeParse) {
|
||||
this.Expression = expression;
|
||||
this.FreeParse = freeParse;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内置解析功能,可辅助您进行解析
|
||||
/// </summary>
|
||||
public Func<Expression, string> FreeParse { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 需要您解析的表达式
|
||||
/// </summary>
|
||||
public Expression Expression { get; }
|
||||
/// <summary>
|
||||
/// 解析后的内容
|
||||
/// </summary>
|
||||
public string Result { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +95,10 @@ public interface IFreeSql {
|
||||
/// 数据库访问对象
|
||||
/// </summary>
|
||||
IAdo Ado { get; }
|
||||
/// <summary>
|
||||
/// 所有拦截方法都在这里
|
||||
/// </summary>
|
||||
IAop Aop { get; }
|
||||
|
||||
/// <summary>
|
||||
/// CodeFirst 模式开发相关方法
|
||||
|
Reference in New Issue
Block a user