......或者我应该说,使用MVC的Enterprise Library 5 VAB最简洁的方法是什么?MVC UpdateModel可以使用Enterprise Library VAB吗?
我目前使用的形式:
ActionResult Save(int id, FormCollection form)
{
SomeModel model = somehowgetbyid(id);
UpdateModel(model);
somehowvalidate(model);
if(ModelState.IsValid)
{
etc...
能VAB装饰类自动地通过的UpdateModel验证,还是我手动得到验证,并且调用后验证呢? 或者还有更好的方法吗?
是的。这是因为VAB属性继承自DataAnnotations的基本验证属性。 MVC本身与DataAnnotations属性一起使用。 – Steven 2011-04-18 10:25:18
我所做的一个观察是,如果涉及规则集,则不调用默认规则集。它只是让模型绑定器跳过验证属性。 – 2011-05-12 11:06:35