鉴于以下内容
[Test]
public void VerifyMappings()
{
new PersistenceSpecification<Address>(Session)
.CheckProperty(x => x.AddressLine1, "190 House 12")
.VerifyTheMappings();
}
以下内容将尝试对数据库进行读写操作,但是它会保留记录。是否可以使用流畅的框架删除此记录?
答案 0 :(得分:3)
在[TearDown]
:
var currentSession = NHibernateSession.Current;
if (currentSession.Transaction.IsActive) {
currentSession.Flush();
currentSession.Transaction.Rollback();
}
这将回滚当前的交易。