I inherited from DefaultModelBinder, because it automatically binds basic properties in entity. I enhanced it, so it binds also navigation properties. My binder performs inherited binding first and then searches for additional, navigation property values in form. I think that Your approach should depend on what You really want to do. You can also use reflector and see what really stands behind default binder. This may convince You to inherit.
发布评论
评论(4)
K Scott Allen 对于模型绑定有一些建议:
http ://odetocode.com/blogs/scott/archive/2009/04/27/6-tips-for-asp-net-mvc-model-binding.aspx。
K Scott Allen has some tips about Model Binding:
http://odetocode.com/blogs/scott/archive/2009/04/27/6-tips-for-asp-net-mvc-model-binding.aspx.
我继承自DefaultModelBinder,因为它自动绑定实体中的基本属性。我增强了它,因此它还绑定了导航属性。我的绑定器首先执行继承的绑定,然后在表单中搜索其他导航属性值。我认为你的方法应该取决于你真正想做的事情。您还可以使用 Reflector 来查看默认活页夹背后的真正含义。这可能会说服您继承。
I inherited from DefaultModelBinder, because it automatically binds basic properties in entity. I enhanced it, so it binds also navigation properties. My binder performs inherited binding first and then searches for additional, navigation property values in form. I think that Your approach should depend on what You really want to do. You can also use reflector and see what really stands behind default binder. This may convince You to inherit.
Travis Illig 最近写了一篇非常好的博客文章,介绍创建自定义模型绑定程序时的数据类型验证。
我以前从未见过这个建议,我认为它真的很好 - 所以我想贡献这个链接:http://www.paraesthesia.com/archive/2012/01/31/data-type-validation-and -模型绑定-in-asp-net-mvc.aspx
Travis Illig recently wrote a really good blog article about data type validation when creating a custom model binder.
I've never seen this advice before and I thought it was really good - so I wanted to contribute this link: http://www.paraesthesia.com/archive/2012/01/31/data-type-validation-and-model-binding-in-asp-net-mvc.aspx
MVC Futures 2 有一个可扩展的模型绑定系统。您可以在发布文档中找到更多信息 http://aspnet.codeplex.com/releases/ view/41742
只需下载“ASP.NET MVC 2 Futures 可扩展模型绑定器文档”
MVC Futures 2 has an extensible model binding system. You can find out more in the release documentation at http://aspnet.codeplex.com/releases/view/41742
Just download "ASP.NET MVC 2 Futures Extensible Model Binder Documentation"