• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Kevin Cheng's Yard
电脑是我的老婆,编程是我的灵魂,代码是我的语言,按键是我在歌唱。
https://github.com/surfsky/
博客园    首页    新随笔    联系   管理    订阅  订阅

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 

posted @ 2006-06-29 16:14  surfsky  阅读(518)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3