Castle ActiveRecord学习实践(3) 映射基础2011-02-03 cnblogs terrylee主要内容简单映射1.ActiveRecordAttribute2. PrimaryKeyAttribute3.CompositeKeyAttribute4.PropertyAttribute5.FieldAttribute一.ActiveRecordAttribute每一个实体类都必须继承于基类ActiveRecordBase,并在实体类上设置特性ActiveRecordAttribute,示例代码
//指定数据库表名
[ActiveRecord("Blogs")]
public class Blog : ActiveRecordBase
{
//
}
//不指定数据库表名
[ActiveRecord]
public class Blog : ActiveRecordBase
{
//
}ActiveRecordAttribute说明
| 属性 | 说明 | 示例 |
| Table | 指定持久化类所对应的数据库表名,如果表名与类名相同,可以省略 | [ActiveRecord("Blogs")] [ActiveRecord(Table="Blogs")] |
| Schema | 指定Schema的名字 | Schema="ARDemo" |
| Proxy | 指定一个接口,在延迟装载时作为代理使用 | |
| DiscriminatorColumn | 识别器的字段名 | DiscriminatorColumn="Blog" |
| DiscriminatorType | 识别器的字段类型 | DiscriminatorType="String" |
| DiscriminatorValue | 识别器字段的值 | |
| Where | 指定一个附加SQL的Where子句 | Where="IsPost = 0" |
| Lazy | 指定是否延迟加载 | Lazy=true|false |