I have a SQL Server 2012 table containing file records. Each record has a column varbinary(max) BlobDatathat represents the data stored in the file. The data size can be more than 1 GB and cannot fit in RAM, so I don’t want it to be supported by byte. I would like to implement two streaming operations:
- sequential reading of the string
BlobDatain pieces to the buffer; - sequentially rewriting a string
BlobDatain chunks using a buffer.
Using simple ADO.NET, an easy way to achieve this is to use SqlDataReaderand UPDATE .WRITE():
using (SqlDataReader reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.SequentialAccess))
{
while (reader.Read())
{
byte[] buffer = new byte[size];
while ((count = reader.GetBytes(0, offset, buffer, 0, buffer.Length)) > 0)
{
DoStuffWithBuffer(buffer);
offset += count;
}
}
}
UPDATE [File] SET [BlobData].WRITE(@buffer, @offset, @count)
WHERE [FileID]=@id
, , EF , ADO.NET. , , EF6 , EntityDataReader.GetBytes(), , MSDN, , , dataIndex, , , bufferIndex ".
, EntityDataReader.GetBytes() SqlDataReader.GetBytes() - ?
EF6 , UPDATE .WRITE(buffer, offset, count) varbinary(max)?
EF6, , EF6.
EF6, / EF6, ADO.NET, ? .NET 4.0.