Ver código fonte

fix: 修复忽略更新字段为空时更新报错的bug

喵你个旺呀 1 ano atrás
pai
commit
f647f0c874

+ 7 - 3
Admin.NET/Admin.NET.Web.Entry/wwwroot/template/Service.cs.vm

@@ -132,11 +132,15 @@ public class @(Model.ClassName)Service : IDynamicApiController, ITransient
         }
         }
         var entity = input.Adapt<@(Model.ClassName)>();
-        await _@(Model.LowerClassName)Rep.AsUpdateable(entity).IgnoreColumns(u => new {
-        @foreach (var column in Model.IgnoreUpdateFieldList) {
+        await _@(Model.LowerClassName)Rep.AsUpdateable(entity)
+        @if (Model.IgnoreUpdateFieldList.Count > 0) {
+        @:.IgnoreColumns(u => new {
+        foreach (var column in Model.IgnoreUpdateFieldList) {
             @:u.@(column.PropertyName),
         }
-        }).ExecuteCommandAsync();
+        @:})
+        }
+        .ExecuteCommandAsync();
     }
 
     /// <summary>