的DataAnnotations或应用程序验证模块 [英] DataAnnotations or Application Validation block

查看:130
本文介绍了的DataAnnotations或应用程序验证模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我的DataAnnotations和应用验证模块之间的区别?

Whats the difference between DataAnnotations and Application Validation Block?

推荐答案

的DataAnnotations是一个属性的基础模型,以'注释'你的数据,它是在.NET框架本身。其最明显的用途是用于验证,ASP.NET MVC做了实例。验证应用程序块本身是一个验证框架,由微软P&放大​​器产生;普队,但它不是.NET Framework的一部分。它还包含了属性注释的数据,并在其最新版本(5.0)的属性从继承的DataAnnotations,使其可与的DataAnnotations在一定程度上。

DataAnnotations is an attribute based model to 'annotate' your data and it is in the .NET framework itself. Its most obvious use is for validation, as ASP.NET MVC does for instance. Validation Application Block itself is a validation framework, created by the Microsoft P&P team, but it is not part of the .NET framework. It also contains attributes to 'annotate' your data and in its newest version (5.0) the attributes inherit from DataAnnotations, making it interchangeable with DataAnnotations to some extent.

验证应用程序块,或整个企业图书馆其实,更侧重于企业发展。 VAB让许多更复杂的情况。比如,它可以让你把配置文件中的验证规则,或(有工作)在code。它也允许一个名为规则集功能,允许组验证和触发只有一个单一的一组规则的对象。有没有什么你不能做什么验证涉及VAB,但是这当然是有代价的。价格是复杂性。虽然设计合理,VAB是不容易学习,因为我还在学习新的方法来做事的。

Validation Application Block, or the whole Enterprise Library actually, is more focused on enterprise development. VAB allows many more complex scenarios. For instance it allows you to put the validation rules in configuration files, or (with a bit of work) in code. It also allows a feature called 'rulesets', allowing to group validations and trigger only a single group of rules on an object. There isn’t much you cannot do what validation is concerned with VAB, but this of course comes at a price. The price is complexity. While designed properly, VAB is not easy to learn as I’m still learning new ways to do things with it.

相比的DataAnnotations,的DataAnnotations是很容易的,但也很有限,当涉及到更复杂的情况。

Compared to DataAnnotations, DataAnnotations is very easy, but also very limited when it comes to more complex scenarios.

这篇关于的DataAnnotations或应用程序验证模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆