Castle.ActiveRecord 学与练[3]下

第二部分:源码讲解
ActiveRecordAttribute:
对于ActiveRecordAttribute来说,其中比较重要的参数就是Table了,用它来确定这个实体指向哪个数据库表.不填表示类实体名与数据库表名相同.
        [ActiveRecord(Table = "Users",Schema = "Training",Where = "1 = 1")]
        public class Users : ActiveRecordBase
        {
            
                    }

PrimaryKeyAttribute:
对于PrimaryKeyAttribute来说,顾名思义此特性是为了设置主键而设计的,其中PrimaryKeyType为大家提供了多种类型可以应付各种情况,详见上面表格.

[PrimaryKey(PrimaryKeyType.Identity, Column = "LogonID",ColumnType = "Int32")]
                public int Id
                {
                        get { return _id; }
                        set { _id = value; }
                            }

Property Attribute:
对于PropertyAttribute来说Column参数相对重要,用它来确定属性对应数据库表中哪个字段,如果为空则字段名与属性名相同.
                [Property(Column = "Name", NotNull = true, ColumnType = "String")]
                public string Name
                {
                        get { return _name; }
                        set { _name = value; }
                }


    最近真是太忙了,SAP一直在我们周围转啊转,终于到了要上线的地步了.
    写了这一些,先给大家看看吧,下一篇会在数据的操作上向大家演示Castle.ActiveRecord的奇妙之处,以完成Castle的Castle.ActiveRecord部分,敬请关注. 

     谢谢Terrylee
老师的教程对我的帮助.
    QQ:22566547;
    MSN:[email protected];
    SITE:WWW.MOBILEBETA.NET

你可能感兴趣的:(AOP,Web,mvc,ActiveRecord,休闲,Castle)