File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
src/shared/Z.EF.Plus.QueryFuture.Shared Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,7 @@ public void ExecuteQueries()
183183
184184 using ( command )
185185 {
186+ QueryFutureManager . OnBatchExecuting ? . Invoke ( command ) ;
186187#if EF5
187188 using ( var reader = command . ExecuteReader ( ) )
188189 {
@@ -213,6 +214,7 @@ public void ExecuteQueries()
213214 }
214215 }
215216#endif
217+ QueryFutureManager . OnBatchExecuted ? . Invoke ( command ) ;
216218 }
217219 }
218220 finally
Original file line number Diff line number Diff line change 77
88using System . Runtime . CompilerServices ;
99using Z . EntityFramework . Extensions ;
10+ using System ;
11+ using System . Data . Common ;
1012
1113#if NET45 || EFCORE
1214
@@ -53,6 +55,20 @@ static QueryFutureManager()
5355 /// <value>True if allow query batch, false if not.</value>
5456 public static bool AllowQueryBatch { get ; set ; } = true ;
5557
58+ /// <summary>Gets or sets a delegate to be invoked directly before executing the batch DbCommand.</summary>
59+ /// <remarks>
60+ /// This delegate is only invoked when queries are actually executed as a batch containing multiple queries.
61+ /// i.e. When AllowQueryBatch=false or only a single query is pending, this delegate is not invoked.
62+ /// </remarks>
63+ public static Action < DbCommand > OnBatchExecuting { get ; set ; } = null ;
64+
65+ /// <summary>Gets or sets a delegate to be invoked directly after executing the batch DbCommand.</summary>
66+ /// <remarks>
67+ /// This delegate is only invoked when queries are actually executed as a batch containing multiple queries.
68+ /// i.e. When AllowQueryBatch=false or only a single query is pending, this delegate is not invoked.
69+ /// </remarks>
70+ public static Action < DbCommand > OnBatchExecuted { get ; set ; } = null ;
71+
5672 /// <summary>Gets or sets the weak table used to cache future batch associated to a context.</summary>
5773 /// <value>The weak table used to cache future batch associated to a context.</value>
5874#if EF5 || EF6
You can’t perform that action at this time.
0 commit comments