@@ -17,25 +17,20 @@ namespace DevExtreme.AspNet.Data {
1717
1818 class DataSourceLoaderImpl < S > {
1919 readonly IQueryable < S > Source ;
20-
21- readonly CancellationToken CancellationToken ;
22- readonly bool Sync ;
23-
24- readonly QueryProviderInfo ProviderInfo ;
2520 readonly DataSourceLoadContext Context ;
21+ readonly Func < Expression , ExpressionExecutor > CreateExecutor ;
2622
2723#if DEBUG
2824 readonly Action < Expression > ExpressionWatcher ;
2925 readonly bool UseEnumerableOnce ;
3026#endif
3127
3228 public DataSourceLoaderImpl ( IQueryable < S > source , DataSourceLoadOptionsBase options , CancellationToken cancellationToken , bool sync ) {
33- Source = source ;
34- CancellationToken = cancellationToken ;
35- Sync = sync ;
29+ var providerInfo = new QueryProviderInfo ( source . Provider ) ;
3630
37- ProviderInfo = new QueryProviderInfo ( source . Provider ) ;
38- Context = new DataSourceLoadContext ( options , ProviderInfo , typeof ( S ) ) ;
31+ Source = source ;
32+ Context = new DataSourceLoadContext ( options , providerInfo , typeof ( S ) ) ;
33+ CreateExecutor = expr => new ExpressionExecutor ( Source . Provider , expr , providerInfo , cancellationToken , sync ) ;
3934
4035#if DEBUG
4136 ExpressionWatcher = options . ExpressionWatcher ;
@@ -170,7 +165,7 @@ Task<int> ExecCountAsync(Expression expr) {
170165 ExpressionWatcher ? . Invoke ( expr ) ;
171166#endif
172167
173- var executor = new ExpressionExecutor ( Source . Provider , expr , CancellationToken , Sync ) ;
168+ var executor = CreateExecutor ( expr ) ;
174169
175170 if ( Context . RequireQueryableChainBreak )
176171 executor . BreakQueryableChain ( ) ;
@@ -197,7 +192,7 @@ async Task<IEnumerable<R>> ExecExprAsync<R>(Expression expr) {
197192 ExpressionWatcher ? . Invoke ( expr ) ;
198193#endif
199194
200- var executor = new ExpressionExecutor ( Source . Provider , expr , CancellationToken , Sync ) ;
195+ var executor = CreateExecutor ( expr ) ;
201196
202197 if ( Context . RequireQueryableChainBreak )
203198 executor . BreakQueryableChain ( ) ;
0 commit comments