I'm trying to save image into sql-server using linq. I set the field type to be image, in my application I use a fileupload controler to read the image file as byte[]. Here comes the question, it cannot convert byte[] to binary when I evaluate the image field. Do you think it's a good way to save image?
My code:
Stream imgStream = FileUpload1.PostedFile.InputStream;
int imglen = FileUpload1.PostedFile.ContentLength;
string imgContentType = FileUpload1.PostedFile.ContentType;
string imgName = FileUpload1.PostedFile.FileName;
byte[] imgBinaryData = new byte[imglen];
int n = imgStream.Read(imgBinaryData, 0, imglen);
ImgStore info = new ImgStore();
info.pic = imgBinaryData;// it cannot implictly convert type 'byte[]' to Linq.Binary
info.type = imgContentType;
info.fileName = imgName;