zoukankan      html  css  js  c++  java
  • Gentle.NET Attribute

    ------------------------------------------------------------
    Gentle.NET Attribute
    ------------------------------------------------------------
    数据表特性(用在实体类上)
        [TableName("Product", CacheStrategy.Temporary)]
        注:缓存策略
            public enum CacheStrategy
            {
                Never,           // 每次都直接从数据库获取记录
                Temporary,       // 读取记录后丢到Cache中,并指定失效时间。每次查询时先尝试从cache中获取,若不存在才查询数据库
                Permonent        // 类似Tempory,但不指定失效时间
            }


    数据字段特性
        针对不同的数据库以下特性部分有效,具体请查看pdf文档Page55-57
            [Size]
            [Type]
            [IsNullable]
            [IsUnique]
            [IsPrimaryKey]
            [IsForeignKey]
            [IsAutoGenerated]
        例如:主键,自增字段
      [TableColumn("id", NotNull=true), PrimaryKey(AutoGenerated=true)]
      protected int id;
      [TableColumn("name", NullValue="")]
      protected string name;

         [TableColumn( "ph_Id", NotNull=true ), PrimaryKey( AutoGenerated=true ), SequenceName( "PROPERTYHOLDER_SEQ" )]
         public virtual int Id
         {
          get { return id; }
          set { id = value; }
         }
        Gentle.Framework Attribute
            [Concurrency]
            [CustomView]
            [ForeignKey]
            [Inheritance]
            [PrimaryKey]
            [SequenceName]
            [SoftDelete]
            [TableColumn]
            [TableName]


    数据视图特性(用在Property上)Gentle.Common.Attributes
        以下特性可用在Property上
            [Caption("Caption")]
            [AllowSort(false)]
            [ReadOnly(false)]
            [Visible(false)]
        例如   
            [Caption("Company"), ReadOnly(true)]
            property string CompanyName
            {
                get{ return companyName; }
                set{ companyName = value; }
            }
            [AllowSort(false)]
            public string Name
            {
                get { return mName; }
                set { mName = value; }
            }
            [Visible(false)]
            public string Name
            {
                get { return mName; }
                set { mName = value; }
            }

    数据校验特性 
        [RegexValidator(Expression=@"[A-Z]+[a-z])]
        [RequiredValidator()]
        [RangeValidator( Min=20.5, Max=100.5 )]
     

    转载请注明出处:http://surfsky.cnblogs.com 

  • 相关阅读:
    [做题记录-乱做] [AGC004F] Namori
    字符串分割去除空格
    逆向实战01-嘟嘟牛在线
    mysql超8小时解决
    macbook golang的debug模式不好使
    博客暂时废弃公告
    [干货] 博客园主题
    [Contest on 2021.10.14] 我靠,真的好困!
    [Contest on 2021.10.9] 说好的 100kb 呢?
    [Contest on 2021.10.7] 已经起不了标题了...
  • 原文地址:https://www.cnblogs.com/surfsky/p/438792.html
Copyright © 2011-2022 走看看