我在使用 NHibernate 时遇到了一些奇怪的行为。我正在从存储库中检索学习者列表,并根据需要对其进行更新,奇怪的是当我保存第一个学习者时,对所有学习者所做的更改都被提交到数据库中。
[Transaction]
public void UpdateLearner(Learner learner)
{
//UnitOfWork.CurrentSession.Save(learner);
}
任何想法为什么?我没有启用缓存。我知道它与事务有关,因为即使对 save 方法的调用被注释掉,更改也会持续存在。
这是我的映射:
<class name="Learner" table="ILR_Learner">
<id name="Id" column="ILRLearnerID">
<generator class="native" />
</id>
<property column="LastWarning" name="LastWarning" type="DateTime" />
<property column="Submitted" name="SuccessfulSubmission" type="DateTime" />
<join table="vwLearnerLSCUpload">
<key column="ILRLearnerID" foreign-key="ILRLearnerID"/>
<property column="Dog" type="DateTime" name="Dog"/>
</join>
<join table="Learner">
<key column="Id" foreign-key="ILRLearnerID"/>
<property column="Food" name="Food" type="String" length="20" />
</join>
</class>