Reputation: 2489
I know it´s a pretty simple question, but what happens when one calls ISession.Delete with a transient entity? I suspect that an exception is thrown, but could not find anything in the documentation.
Upvotes: 0
Views: 687
Reputation: 1157
It will NOT throw any exception and it will NOT make any db call.
here is the unit test which pass:
[Test]
public void TestDeletionOnTransientObject()
{
NormalSalesFlowActivity normalSalesFlowActivity =
Factories.SalesFlowActivityFactory.CreateNormalSalesFlowActivities(null,
opt => opt.NoOfEntities(1)).First();
Assert.That(normalSalesFlowActivity.Id, Is.EqualTo(0));
Session.Delete(normalSalesFlowActivity);
}
First parameter of CreateNormalSalesFlowActivies is the NH Session, if it is supplied when entity is attached to Session and by default is stored to db.
Regards
Upvotes: 1