2

Following up from Avoiding the LOH when reading a binary

In Nhibernate would it be possible to save a Stream to database in chunks?

With the following code, a FileStream is opened and its contents are read in 2kb chunks:

using (var fs = new FileStream(path, FileMode.Open))
{
    byte[] buffer = new byte[2048];
    int bytesRead;
    while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0)
    {
        //// somehow push the contents of the buffer to the database        
    }
}

Usually objects are persisted in one operation, can it be done incrementally?

Community
  • 1
  • 1
user1838662
  • 503
  • 7
  • 17

0 Answers0