【发布时间】:2015-03-17 04:46:29
【问题描述】:
我在 NHibernate 参考文档中阅读了第 10 章“只读实体”,如下所示:
http://nhibernate.info/doc/nh/en/index.html#readonly
但不幸的是,我不知道为什么要使用只读实体。我想我需要一些背景知识来理解它,例如:
1. immutable classes 是指 C# 代码中的“静态”类?让我们用代码来显示它
public class entity
{
public virtual int Id {get; }
public virtual DateTime CreatedTime
{
get;
//how about I add this becasue it should be set before session.Save()
private set;
}
}
- 出于性能原因使用只读实体?(无脏检查并保存内存)
- 只读实体不会永久保留 ......
任何解释都有帮助,非常感谢。
【问题讨论】:
-
我在映射到数据库视图的情况下使用
mutable="false"。其他两个问题真的没有意义。
标签: nhibernate readonly