Merge pull request #724 from jianxuanbing/master

fix: 修复byte[]类型的乐观锁初始化问题
This commit is contained in:
IGeekFan 2021-03-30 06:26:54 -08:00 committed by GitHub
commit 847cc7838c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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()));
} }
} }