using System.ComponentModel.DataAnnotations

出自http://www.cnblogs.com/9988/archive/2012/04/25/2469838.html看了网上的一些介绍,还是这篇将的好
 

在Entity Framworik(Module)中有两种配置:一种 DataAnnotaions(注释)与Fluent API.这些根据个人喜欢来使用,DataAnnotaions 配置相对简单些,Fluent API可以配置些复杂的功能。

今天我们来简单说说DAtaAnnotaions 的属性--

命名空间:System.ComponentModel.DataAnnotations

四个属性:

属性名称

描述

Required

标识该属性为必需参数,不能为空

StringLength

标识该字符串有长度限制,可以限制最小或最大长度

Range

标识该属性值范围,通常被用在数值型和日期型

RegularExpression

标识该属性将根据提供的正则表达式进行对比验证

CustomValidation

标识该属性将按照用户提供的自定义验证方法,进行数值验证

posted @ 2013-01-25 14:27  曉軒  阅读(753)  评论(0编辑  收藏  举报