I have winforms that contains pictureBox form, I want to retrieve an img from DB to that control using LINQ.
This is the error when compiling,
CS1061: IQueryable does not contain a definition for Image and no extension method Image accepting a first argument of type IQueryable could be found (are you missing a using directive or an assembly reference?)
private void pictureBox1_Click(object sender, EventArgs e)
{
// Get as single image from the database
var q = from image in context.Products
where image.Pro_ID == 1
select image;
// Convert the byte[] to an System.Drawing.Image
img.Image = ByteArrayToImage(q.Image.ToArray());
}
private byte[] ImageToByteArray(System.Drawing.Image imageIn)
{
using (MemoryStream ms = new MemoryStream())
{
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
return ms.ToArray();
}
}