Follow code:
byte[] image1 = ConvertTo.Bytes(Request.Files[0]);
byte[] image2 = null;
ctx
.Users
.Where(x => x.Id == 1)
.Update(x => new User()
{
ImageByte1 = image1,
ImageByte2 = image2
});
Table definition:
ImageByte1 varbinary(MAX) Allow nulls? true
ImageByte2 varbinary(MAX) Allow nulls? true
I use this one here: http://entityframework-plus.net/
Only problem if I set null to ImageByte2
. Following error:
The implicit conversion of the nvarchar data type into varbinary (max) is not allowed. Use the CONVERT function to perform this query
Now its I define ImageByte1
and ImageByte2
as null
, it does update normally or ImageByte1
and ImageByte2
other than null also does update.
Any solution ?
The problem has already been corrected with the most up-to-date version.
Nuget: https://www.nuget.org/packages/Z.EntityFramework.Plus.EF6/