@@ -47,33 +47,32 @@ public NDataReader(DbDataReader reader, bool isMidstream)
47
47
{
48
48
var resultList = new List < NResult > ( 2 ) ;
49
49
50
- try
50
+ using ( reader )
51
51
{
52
- // if we are in midstream of processing a DataReader then we are already
53
- // positioned on the first row (index=0)
54
- if ( isMidstream )
52
+ try
55
53
{
56
- currentRowIndex = 0 ;
57
- }
54
+ // if we are in midstream of processing a DataReader then we are already
55
+ // positioned on the first row (index=0)
56
+ if ( isMidstream )
57
+ {
58
+ currentRowIndex = 0 ;
59
+ }
58
60
59
- // there will be atleast one result
60
- resultList . Add ( new NResult ( reader , isMidstream ) ) ;
61
+ // there will be atleast one result
62
+ resultList . Add ( new NResult ( reader , isMidstream ) ) ;
61
63
62
- while ( reader . NextResult ( ) )
64
+ while ( reader . NextResult ( ) )
65
+ {
66
+ // the second, third, nth result is not processed midstream
67
+ resultList . Add ( new NResult ( reader , false ) ) ;
68
+ }
69
+
70
+ results = resultList . ToArray ( ) ;
71
+ }
72
+ catch ( Exception e )
63
73
{
64
- // the second, third, nth result is not processed midstream
65
- resultList . Add ( new NResult ( reader , false ) ) ;
74
+ throw new ADOException ( "There was a problem converting an DbDataReader to NDataReader" , e ) ;
66
75
}
67
-
68
- results = resultList . ToArray ( ) ;
69
- }
70
- catch ( Exception e )
71
- {
72
- throw new ADOException ( "There was a problem converting an DbDataReader to NDataReader" , e ) ;
73
- }
74
- finally
75
- {
76
- reader . Close ( ) ;
77
76
}
78
77
}
79
78
@@ -108,7 +107,7 @@ public override int RecordsAffected
108
107
109
108
public override bool HasRows
110
109
{
111
- get { return results . LongLength > 0 ; }
110
+ get { return results . Length > 0 ; }
112
111
}
113
112
114
113
/// <summary></summary>
@@ -135,10 +134,12 @@ public override bool NextResult()
135
134
}
136
135
137
136
/// <summary></summary>
137
+ #if FEATURE_DATA_CLOSE || NET_4_0
138
138
public override void Close ( )
139
139
{
140
140
isClosed = true ;
141
141
}
142
+ #endif
142
143
143
144
/// <summary></summary>
144
145
public override bool Read ( )
@@ -163,11 +164,17 @@ public override int Depth
163
164
get { return currentResultIndex ; }
164
165
}
165
166
167
+ #if FEATURE_DATA_GETSCHEMATABLE || NET_4_0
166
168
/// <summary></summary>
167
169
public override DataTable GetSchemaTable ( )
168
170
{
171
+ #if FEATURE_DATA_GETSCHEMATABLE
169
172
return GetCurrentResult ( ) . GetSchemaTable ( ) ;
173
+ #else
174
+ throw new NotImplementedException ( ) ;
175
+ #endif
170
176
}
177
+ #endif
171
178
172
179
protected override void Dispose ( bool disposing )
173
180
{
@@ -247,7 +254,7 @@ public override long GetBytes(int i, long fieldOffset, byte[] buffer, int buffer
247
254
length = ( int ) remainingLength ;
248
255
}
249
256
250
- Array . Copy ( cachedByteArray , fieldOffset , buffer , bufferOffset , length ) ;
257
+ Array . Copy ( cachedByteArray , ( int ) fieldOffset , buffer , bufferOffset , length ) ;
251
258
252
259
return length ;
253
260
}
@@ -422,7 +429,7 @@ public override long GetChars(int i, long fieldOffset, char[] buffer, int buffer
422
429
length = ( int ) remainingLength ;
423
430
}
424
431
425
- Array . Copy ( cachedCharArray , fieldOffset , buffer , bufferOffset , length ) ;
432
+ Array . Copy ( cachedCharArray , ( int ) fieldOffset , buffer , bufferOffset , length ) ;
426
433
427
434
return length ;
428
435
}
@@ -466,7 +473,9 @@ private class NResult
466
473
private readonly object [ ] [ ] records ;
467
474
private int colCount = 0 ;
468
475
476
+ #if FEATURE_DATA_GETSCHEMATABLE
469
477
private readonly DataTable schemaTable ;
478
+ #endif
470
479
471
480
// key = field name
472
481
// index = field index
@@ -485,7 +494,9 @@ private class NResult
485
494
/// </param>
486
495
internal NResult ( DbDataReader reader , bool isMidstream )
487
496
{
497
+ #if FEATURE_DATA_GETSCHEMATABLE
488
498
schemaTable = reader . GetSchemaTable ( ) ;
499
+ #endif
489
500
490
501
List < object [ ] > recordsList = new List < object [ ] > ( ) ;
491
502
int rowIndex = 0 ;
@@ -561,11 +572,13 @@ public string GetName(int colIndex)
561
572
return fieldIndexToName [ colIndex ] ;
562
573
}
563
574
575
+ #if FEATURE_DATA_GETSCHEMATABLE
564
576
/// <summary></summary>
565
577
public DataTable GetSchemaTable ( )
566
578
{
567
579
return schemaTable ;
568
580
}
581
+ #endif
569
582
570
583
/// <summary>
571
584
///
@@ -635,4 +648,4 @@ public int RowCount
635
648
}
636
649
}
637
650
}
638
- }
651
+ }
0 commit comments