After an edit, this code generates a bitmap and writes it to a hdd file. How do I save this in my db?
// first save the edit data
Actionresult Edit (Lot Lot)
{ remove scaffold code for clarity
db.SaveChanges();
// create a new image to replace image currently in db.
Bitmap mybmp = new Bitmap(400, 20);
Graphics g = Graphics.FromImage(mybmp);
g.DrawRectangle(Pens.Black, 0, 0, 400, 20);
SolidBrush b = new SolidBrush(Color.OldLace);
g.FillRectangle(b, 0, 0, 400, 20);
// write a test file to confirm this is ok ------it works
mybmp.Save("C:\\temp\\lot1.bmp",System.Drawing.Imaging.ImageFormat.Gif);
// add code here to save image to Lot table field TaskImage here
db.SaveChanges();
}
My class:
public class Lot
{
public int LotID { get; set; }
public byte?[] TaskImage { get; set; }
}