As shown in the Working with Streams documentation article
, a stream is read at multiple passes retrieving the data at chunks. Reading this stream is done manually and it requires calls to the database meaning that reading it though a detached object would result in InvalidOperationException
with the following explanation: Instance is detached, no database operation can be made.
This means that if you would like to detach an object along with its BinaryStream
property, the first
think you have to do is to read and manually store the binary data before
the object is detached. Once you have stored the data you could then detach the object. Both how to read and then re-attach such an object is demonstrated in the Working with Streams documentation article
(also linked above).
Alternative approach could be to map this column to byte
property instead of BinaryStream
. This would allow you to include it in the properties to be detached (as you have shown that you do) and detach it. Please note that detaching binary column in such way could lead to performance degradation depending on the size of the retrieved data. Also taking this approach you will lose the ability to easily stream the data.
I hope this is helpful. Do not hesitate to get back to us if you have any more questions or if you need any further assistance.
OpenAccess ORM is now Telerik Data Access
. For more information on the new names, please, check out the Telerik Product Map