zoukankan      html  css  js  c++  java
  • MVC数据注解

    数据注解

    using System.ComponentModel.DataAnnotations;

    KeyAttribute 唯一主键
    StringLengthAttribute 字符串长度约束
    MaxLengthAttribute 最大长度
    ConcurrencyCheckAttribute 并发检查属性
    RequiredAttribute 非空
    TimestampAttribute
    ComplexTypeAttribute
    ColumnAttribute  置于一个属性上,指定其字段名,序数和数据类型
    TableAttribute  置于一个类上,指定其数据表名和定义
    InversePropertyAttribute   置于一个导航属性上,指定代表关系另一端的属性
    ForeignKeyAttribute   置于一个导航属性上,指定代表关系外键的属性
    DatabaseGeneratedAttribute   置于一个属性上,指定数据库该如何为该属性生成值(Identity, Computed 或者 None)
    NotMappedAttribute   置于一个属性或类上,将其排除在数据库外

    //[DisplayName]:显示名 – 定义表单字段的提示名称
    //[Required] :必须 – 表示这个属性是必须提供内容的字段
    //[StringLength]:字符串长度 – 定义字符串类型的属性的最大长度
    //[Range]:范围 – 为数字类型的属性提供最大值和最小值
    //[RegularExpression]:正则表达式 – 指定动态数据中的数据字段值必须与指定的正则表达式匹配

    using System.ComponentModel.DataAnnotations.Schema;

    [NotMapped]:表示该属性不对应数据库中的字段

  • 相关阅读:
    Resharper的使用
    SQL Server 占用CPU较高的解决方法
    014 FPGA千兆网UDP通信
    012 PCIe总线的基础知识
    008 PCI设备BAR空间的初始化
    016 基于FPGA的网口通信实例设计【转载】
    015 FPGA千兆网TCP通信【转载】
    006 PCI总线的桥与配置(一)
    004 PCI Express体系结构(四)
    007 PCI总线的桥与配置(二)
  • 原文地址:https://www.cnblogs.com/xsj1989/p/5556337.html
Copyright © 2011-2022 走看看