如何设置真正的查询更新?我无法得到这部分
var image = add.Image.ToArray();
我必须从UserImage
string fileName = FileUpload1.FileName;
byte[] fileByte = FileUpload1.FileBytes;
Binary binaryObj = new Binary(fileByte);
var add = from u in db.UserImage
where u.User_Id == id
select u;
foreach (var u in update7)
{
u.Image = binaryObj;
u.ImageObj = fileName;
}
db.SubmitChanges();
var image =*add.Image*.ToArray();
byte[] foto = (byte[])image;
TypeConverter cc = TypeDescriptor.GetConverter(typeof(Bitmap));
Bitmap my = (Bitmap)cc.ConvertFrom(foto);
string img = Convert.ToBase64String(foto);
Image1.ImageUrl = string.Format("data:image/Bmp;base64,{0}", img);
答案 0 :(得分:0)
var add = from u in db.UserImage
where u.User_Id == id
select u;
foreach (var u in add)
{
u.Image = binaryObj;
u.ImageObj = fileName;
}
db.SaveChanges();
答案 1 :(得分:0)
我解决了
var add = (from u in db.UserImage
where u.User_Id == id
select u).ToList();
foreach (var u in add)
{
u.Image = binaryObj;
u.ImageObj = fileName;
}
db.SubmitChanges();
var image = add[0].Image.ToArray();