遵循代码:
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
});
表定义:
ImageByte1 varbinary(MAX) Allow nulls? true
ImageByte2 varbinary(MAX) Allow nulls? true
我在这里使用这个:http://entityframework-plus.net/
只有当我将 null 设置为 ImageByte2
时才会出现问题。以下错误:
The implicit conversion of the nvarchar data type into varbinary (max) is not allowed. Use the CONVERT function to perform this query
现在我将 ImageByte1
和 ImageByte2
定义为 null
,它会正常更新或 ImageByte1
和 ImageByte2
除了 null 之外也会更新。
有什么解决办法吗?
最佳答案
该问题已通过最新版本得到纠正。
Nuget:https://www.nuget.org/packages/Z.EntityFramework.Plus.EF6/
关于c# - 不允许将 nvarchar 数据类型隐式转换为 varbinary (max)。使用 CONVERT 函数执行此查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47232657/