Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.