2

关注代码:

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) 允许空值吗?真的

ImageByte2 varbinary(MAX) 允许空值吗?真的

我在这里使用这个:http: //entityframework-plus.net/

如果我将 null 设置为ImageByte2. 以下错误:

不允许将 nvarchar 数据类型隐式转换为 varbinary (max)。使用 CONVERT 函数执行此查询

现在我将它定义为ImageByte1,它确实会正常更新,或者除了null 之外,它也会更新。ImageByte2nullImageByte1ImageByte2

有什么解决办法吗?

4

1 回答 1

1

该问题已通过最新版本得到纠正。

Nuget:https ://www.nuget.org/packages/Z.EntityFramework.Plus.EF6/

于 2017-11-29T13:08:21.240 回答