-
-
Save gtechsltn/fe436f6e637fd1c6de1675a97bf045ae to your computer and use it in GitHub Desktop.
Revisions
-
brentworden renamed this gist
Aug 30, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
brentworden revised this gist
Jun 15, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public static byte[] GetBytes(this IDataReader reader, int column) { long offset = 0L; long n = 0L; do { n = reader.GetBytes(column, offset, buff, 0, buff.Length); ms.Write(buff, 0, (int)n); offset += n; } while (n >= buff.Length); -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ using System.Data; using System.IO; namespace Extensions.Data { public static class DataReaderExtensions { /* * Extension method on IDataReader that reads the entire contents of a large binary column using a single method call. * Sample usage: * byte[] bytes = reader.GetBytes(columnIndex); */ public static byte[] GetBytes(this IDataReader reader, int column) { using (MemoryStream ms = new MemoryStream()) { byte[] buff = new byte[8192]; long offset = 0L; long n = 0L; do { n = reader.GetBytes(5, offset, buff, 0, buff.Length); ms.Write(buff, 0, (int)n); offset += n; } while (n >= buff.Length); return ms.ToArray(); } } } }