When I inspect the BinaryType.Get method, I saw some comments which surprised me let me think that this method isn't really finished.
Let see by yourself.
Code:
public override object Get( IDataReader rs, int index )
{
if( Environment.UseStreamsForBinary )
{
// Is this really necessary?
// see http://msdn.microsoft.com/library/en-us/cpguide/html/cpconobtainingblobvaluesfromdatabase.asp?frame=true
// for a how to on reading binary/blob values from a db...
MemoryStream outputStream = new MemoryStream( 2048 );
byte[ ] buffer = new byte[2048];
long fieldOffset = 0;
try
{
while( true )
{
long amountRead = rs.GetBytes( index, fieldOffset, buffer, 0, buffer.Length );
fieldOffset += amountRead;
outputStream.Write( buffer, 0, ( int ) amountRead );
if( amountRead < buffer.Length )
{
break;
}
}
outputStream.Close();
}
catch( IOException ioe )
{
throw new HibernateException( "IOException occurred reading a binary value", ioe );
}
return outputStream.ToArray();
}
else
{
//TODO: not sure if this will work with all dbs
return ( byte[ ] ) rs[ index ];
}
}
Is this really necessary ?
At this time, the else part is never executed because
Environment.UseStreamsForBinary return always
true.
So I think this need to be explored deeply because if the else part work with all dbs, this is the solution.