fix: 修复byte[]类型的乐观锁初始化问题

This commit is contained in:
jian玄冰 2021-03-23 16:50:29 +08:00
parent cad97b37ba
commit b6b9281f71

View File

@ -179,7 +179,7 @@ namespace FreeSql.Internal.CommonProvider
} }
if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false) if (val == null && col.Attribute.MapType == typeof(string) && col.Attribute.IsNullable == false)
col.SetValue(data, val = ""); col.SetValue(data, val = "");
if (val == null && col.Attribute.MapType == typeof(byte[]) && col.Attribute.IsVersion) if (col.Attribute.MapType == typeof(byte[]) && (val == null || (val is byte[] bytes && bytes.Length == 0)) && col.Attribute.IsVersion)
col.SetValue(data, val = Utils.GuidToBytes(Guid.NewGuid())); col.SetValue(data, val = Utils.GuidToBytes(Guid.NewGuid()));
} }
} }