Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

去掉UserModel #99

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions NewLife.CubeNC/Common/EntityModelBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace NewLife.Cube;

/// <summary>实体模型绑定器</summary>
class EntityModelBinder : ComplexTypeModelBinder

Check warning on line 15 in NewLife.CubeNC/Common/EntityModelBinder.cs

View workflow job for this annotation

GitHub Actions / test

'ComplexTypeModelBinder' is obsolete: 'This type is obsolete and will be removed in a future version. Use ComplexObjectModelBinder instead.'
{
/// <summary>实例化实体模型绑定器</summary>
/// <param name="propertyBinders"></param>
Expand All @@ -31,10 +31,6 @@
// 如果提交数据里面刚好有名为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 @@
// 强行绑定会出错记录在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
Loading