Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot convert from 'System.Data.Linq.Binary' to 'System.IO.BinaryReader'

my table column is:

AttachContent   varbinary   (max)

when i try to retrieve the data and i get this below error, i am using linq

cannot convert from 'System.Data.Linq.Binary' to 'System.IO.BinaryReader'

like image 932
Nick Kahn Avatar asked Feb 27 '23 10:02

Nick Kahn


1 Answers

System.Data.Linq.Binary contains a byte array. You can use it directly like this:

Binary binary = //your linq object
byte[] array = binary.ToArray();

If you must have a BinaryReader on the byte array you can wrap it up like this:

BinaryReader reader = new BinaryReader(new MemoryStream(binary.ToArray()));
like image 54
Mikael Svenson Avatar answered Apr 27 '23 18:04

Mikael Svenson