22{
33 using System ;
44 using System . Collections . Generic ;
5- using System . Linq ;
65 using System . Data ;
6+ using System . Linq ;
77
8- class AdoAdapterQueryRunner
8+ internal class AdoAdapterQueryRunner
99 {
1010 private readonly AdoAdapter _adapter ;
1111
@@ -14,8 +14,9 @@ public AdoAdapterQueryRunner(AdoAdapter adapter)
1414 _adapter = adapter ;
1515 }
1616
17- public IEnumerable < IDictionary < string , object > > RunQuery ( SimpleQuery query , out IEnumerable < SimpleQueryClauseBase >
18- unhandledClauses )
17+ public IEnumerable < IDictionary < string , object > > RunQuery ( SimpleQuery query ,
18+ out IEnumerable < SimpleQueryClauseBase >
19+ unhandledClauses )
1920 {
2021 if ( query . Clauses . OfType < WithCountClause > ( ) . Any ( ) ) return RunQueryWithCount ( query , out unhandledClauses ) ;
2122
@@ -25,17 +26,18 @@ public IEnumerable<IDictionary<string, object>> RunQuery(SimpleQuery query, out
2526 {
2627 return
2728 CommandBuilder . CreateCommand (
28- _adapter . ProviderHelper . GetCustomProvider < IDbParameterFactory > ( _adapter . SchemaProvider ) , commandBuilders ,
29+ _adapter . ProviderHelper . GetCustomProvider < IDbParameterFactory > ( _adapter . SchemaProvider ) ,
30+ commandBuilders ,
2931 connection ) . ToEnumerable ( _adapter . CreateConnection ) ;
3032 }
3133 return commandBuilders . SelectMany ( cb => cb . GetCommand ( connection ) . ToEnumerable ( _adapter . CreateConnection ) ) ;
3234 }
3335
3436 public IObservable < IDictionary < string , object > > RunQueryAsObservable ( SimpleQuery query ,
35- out
36- IEnumerable
37- < SimpleQueryClauseBase >
38- unhandledClauses )
37+ out
38+ IEnumerable
39+ < SimpleQueryClauseBase >
40+ unhandledClauses )
3941 {
4042 IDbConnection connection = _adapter . CreateConnection ( ) ;
4143 return new QueryBuilder ( _adapter ) . Build ( query , out unhandledClauses )
@@ -69,15 +71,15 @@ out IEnumerable<SimpleQueryClauseBase>
6971
7072 using (
7173 IEnumerator < IEnumerable < IDictionary < string , object > > > enumerator =
72- RunQueries ( new [ ] { countQuery , query } , unhandledClausesList ) . GetEnumerator ( ) )
74+ RunQueries ( new [ ] { countQuery , query } , unhandledClausesList ) . GetEnumerator ( ) )
7375 {
7476 unhandledClauses = unhandledClausesList [ 1 ] ;
7577 if ( ! enumerator . MoveNext ( ) )
7678 {
7779 throw new InvalidOperationException ( ) ;
7880 }
7981 IDictionary < string , object > countRow = enumerator . Current . Single ( ) ;
80- withCountClause . SetCount ( ( int ) countRow . First ( ) . Value ) ;
82+ withCountClause . SetCount ( ( int ) countRow . First ( ) . Value ) ;
8183 if ( ! enumerator . MoveNext ( ) )
8284 {
8385 throw new InvalidOperationException ( ) ;
@@ -101,8 +103,8 @@ private ICommandBuilder[] GetPagedQueryCommandBuilders(SimpleQuery query, Int32
101103
102104 IEnumerable < SimpleQueryClauseBase > unhandledClausesForPagedQuery ;
103105 ICommandBuilder mainCommandBuilder = new QueryBuilder ( _adapter , bulkIndex ) . Build ( query ,
104- out
105- unhandledClausesForPagedQuery ) ;
106+ out
107+ unhandledClausesForPagedQuery ) ;
106108 unhandledClausesList . AddRange ( unhandledClausesForPagedQuery ) ;
107109
108110 const int maxInt = 2147483646 ;
@@ -123,10 +125,13 @@ private ICommandBuilder[] GetPagedQueryCommandBuilders(SimpleQuery query, Int32
123125 }
124126 else
125127 {
126- var commandTexts = queryPager . ApplyPaging ( mainCommandBuilder . Text , skipClause . Count ,
128+ IEnumerable < string > commandTexts = queryPager . ApplyPaging ( mainCommandBuilder . Text , skipClause . Count ,
127129 takeClause . Count ) ;
128130
129- commandBuilders . AddRange ( commandTexts . Select ( commandText => new CommandBuilder ( commandText , _adapter . GetSchema ( ) , mainCommandBuilder . Parameters ) ) ) ;
131+ commandBuilders . AddRange (
132+ commandTexts . Select (
133+ commandText =>
134+ new CommandBuilder ( commandText , _adapter . GetSchema ( ) , mainCommandBuilder . Parameters ) ) ) ;
130135 }
131136 }
132137 return commandBuilders . ToArray ( ) ;
@@ -139,25 +144,26 @@ private ICommandBuilder[] GetQueryCommandBuilders(SimpleQuery query,
139144 {
140145 return GetPagedQueryCommandBuilders ( query , out unhandledClauses ) ;
141146 }
142- return new [ ] { new QueryBuilder ( _adapter ) . Build ( query , out unhandledClauses ) } ;
147+ return new [ ] { new QueryBuilder ( _adapter ) . Build ( query , out unhandledClauses ) } ;
143148 }
144149
145150 private IEnumerable < ICommandBuilder > GetQueryCommandBuilders ( SimpleQuery query , Int32 bulkIndex ,
146- out IEnumerable < SimpleQueryClauseBase > unhandledClauses )
151+ out IEnumerable < SimpleQueryClauseBase >
152+ unhandledClauses )
147153 {
148154 if ( query . Clauses . OfType < TakeClause > ( ) . Any ( ) || query . Clauses . OfType < SkipClause > ( ) . Any ( ) )
149155 {
150156 return GetPagedQueryCommandBuilders ( query , bulkIndex , out unhandledClauses ) ;
151157 }
152- return new [ ] { new QueryBuilder ( _adapter , bulkIndex ) . Build ( query , out unhandledClauses ) } ;
158+ return new [ ] { new QueryBuilder ( _adapter , bulkIndex ) . Build ( query , out unhandledClauses ) } ;
153159 }
154160
155161 public IEnumerable < IEnumerable < IDictionary < string , object > > > RunQueries ( SimpleQuery [ ] queries ,
156- List
157- <
158- IEnumerable
159- < SimpleQueryClauseBase > >
160- unhandledClauses )
162+ List
163+ <
164+ IEnumerable
165+ < SimpleQueryClauseBase > >
166+ unhandledClauses )
161167 {
162168 if ( _adapter . ProviderSupportsCompoundStatements && queries . Length > 1 )
163169 {
@@ -189,4 +195,4 @@ public IEnumerable<IEnumerable<IDictionary<string, object>>> RunQueries(SimpleQu
189195 }
190196 }
191197 }
192- }
198+ }
0 commit comments