第一步:
引入引用using System.ComponentModel.DataAnnotations;
第二部:
在字段前添加限制类型
参考地址:http://blog.csdn.net/chengly0129/article/details/7823157