This commit is contained in:
Master 2024-07-04 17:15:52 +08:00
parent 9622d173b2
commit 2cdeb1a213

View File

@ -170,8 +170,8 @@ public static class SqlSugarSetup
// 新增/插入
if (entityInfo.OperationType == DataFilterType.InsertByObject)
{
// 若主键是长整型且空则赋值雪花Id
if (entityInfo.EntityColumnInfo.IsPrimarykey && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long))
// 若主键是长整型且空且不是自增类型则赋值雪花Id
if (entityInfo.EntityColumnInfo.IsPrimarykey && !entityInfo.EntityColumnInfo.IsIdentity && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long))
{
var id = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue);
if (id == null || (long)id == 0)