Skip to content

Commit

Permalink
Merge pull request #99 from codekgithub/master
Browse files Browse the repository at this point in the history
去掉UserModel
  • Loading branch information
nnhy authored Nov 6, 2024
2 parents ae79ca9 + 04364f1 commit 024280c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions NewLife.CubeNC/Common/EntityModelBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ protected override Object CreateModel(ModelBindingContext bindingContext)
// 如果提交数据里面刚好有名为model的字段,这是Add/Edit接口的入参,则需要清空modelName,否则无法绑定
if (bindingContext.ModelName == "model") bindingContext.ModelName = String.Empty;
}
if (!modelType.As<IEntity>()) return base.CreateModel(bindingContext);

var fact = EntityFactory.CreateFactory(modelType);
if (fact == null) return base.CreateModel(bindingContext);

// 尝试从body读取json格式的参数
var ctx = bindingContext.HttpContext;
Expand All @@ -50,6 +46,10 @@ protected override Object CreateModel(ModelBindingContext bindingContext)
// 强行绑定会出错记录在ModelState,在api中返回400错误,mvc不会
bindingContext.ValueProvider = cubeBodyValueProvider;
}
if (!modelType.As<IEntity>()) return base.CreateModel(bindingContext);

var fact = EntityFactory.CreateFactory(modelType);
if (fact == null) return base.CreateModel(bindingContext);

var pks = fact.Table.PrimaryKeys;
var uk = fact.Unique;
Expand Down

0 comments on commit 024280c

Please sign in to comment.