😎排除自增类型赋值

This commit is contained in:
zuohuaijun 2024-07-04 00:20:37 +08:00
parent 584c2cf49f
commit 1d159ccca6

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)