@@ -22,11 +22,12 @@ public class EFDataReaderLoader : DbDataReader
2222 public EFDataReaderLoader ( DbDataReader dbReader )
2323 {
2424 _dbReader = dbReader ;
25+
2526 _tableRows = new EFTableRows ( _dbReader )
26- {
27- FieldCount = _dbReader . FieldCount ,
28- VisibleFieldCount = _dbReader . VisibleFieldCount ,
29- } ;
27+ {
28+ FieldCount = _dbReader . FieldCount ,
29+ VisibleFieldCount = _dbReader . VisibleFieldCount
30+ } ;
3031 }
3132
3233 /// <summary>
@@ -182,6 +183,7 @@ public EFDataReaderLoader(DbDataReader dbReader)
182183 public override int GetValues ( object [ ] values )
183184 {
184185 Array . Copy ( _rowValues , values , _rowValues . Length ) ;
186+
185187 return _rowValues . Length ;
186188 }
187189
@@ -231,15 +233,17 @@ public override bool Read()
231233 }
232234
233235 _tableRows ? . Add ( new EFTableRow ( _rowValues )
234- {
235- Depth = _dbReader . Depth ,
236- } ) ;
236+ {
237+ Depth = _dbReader . Depth
238+ } ) ;
239+
237240 return true ;
238241 }
239242
240243 private byte [ ] getSqlBytes ( int ordinal )
241244 {
242245 byte [ ] buffer ;
246+
243247 using ( var stream = _dbReader . GetStream ( ordinal ) )
244248 {
245249 if ( stream . Length > int . MaxValue )
@@ -248,12 +252,14 @@ private byte[] getSqlBytes(int ordinal)
248252 }
249253
250254 buffer = new byte [ stream . Length ] ;
255+
251256 if ( stream . Position != 0 )
252257 {
253- stream . Seek ( 0 , SeekOrigin . Begin ) ;
258+ stream . Seek ( offset : 0 , SeekOrigin . Begin ) ;
254259 }
255260
256- var count = stream . Read ( buffer , 0 , checked ( ( int ) stream . Length ) ) ;
261+ var count = stream . Read ( buffer , offset : 0 , checked ( ( int ) stream . Length ) ) ;
262+
257263 if ( count <= 0 )
258264 {
259265 return buffer ;
@@ -266,21 +272,21 @@ private byte[] getSqlBytes(int ordinal)
266272 private bool isBinary ( int ordinal )
267273 {
268274 var typeName = _tableRows . GetFieldTypeName ( ordinal ) ;
269- return string . Equals ( typeName , "Microsoft.SqlServer.Types.SqlGeography" , StringComparison . Ordinal )
270- || string . Equals ( typeName , "Microsoft.SqlServer.Types.SqlGeometry" , StringComparison . Ordinal ) ;
275+
276+ return string . Equals ( typeName , b : "Microsoft.SqlServer.Types.SqlGeography" , StringComparison . Ordinal ) ||
277+ string . Equals ( typeName , b : "Microsoft.SqlServer.Types.SqlGeometry" , StringComparison . Ordinal ) ;
271278 }
272279
273280 /// <summary>
274281 /// Converts a DbDataReader to an EFTableRows
275282 /// </summary>
276- public EFTableRows LoadAndClose ( )
283+ public EFTableRows Load ( )
277284 {
278285 while ( Read ( ) )
279286 {
280287 // Read all data
281288 }
282289
283- Close ( ) ;
284290 return _tableRows ;
285291 }
286292}
0 commit comments