Просмотр исходного кода

!1278 update Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs.
Merge pull request !1278 from Lzh666/N/A

zuohuaijun 2 лет назад
Родитель
Сommit
d4058ab746
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

+ 1 - 1
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

@@ -171,7 +171,7 @@ public static class SqlSugarSetup
             if (entityInfo.OperationType == DataFilterType.InsertByObject)
             {
                 // 若主键是长整型且空则赋值雪花Id
-                if (entityInfo.EntityColumnInfo.IsPrimarykey && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long))
+                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)