What should the following code do?
using (var session1 = sessions.OpenSession())
using (var tx1 = session1.BeginTransaction())
{

    using (var session2 = sessions.OpenSession())
    using (var tx2 = session2.BeginTransaction())
    {
        var employee = session2.Load<Employee>(1);
        Assert.IsFalse(session1.Contains(employee));
        Assert.IsTrue(session2.Contains(employee));

        session1.Evict(employee);

        Assert.IsFalse(session1.Contains(employee));

        Assert.IsTrue(session2.Contains(employee));

        tx2.Commit();
    }

    tx1.Commit();
}

In 1.2 & 2.1, it pass.
In 2.0, it fails with KeyNotFoundException

To me, this is a bug in the user code.
The question is, should we try to warn about this? Or should we ignore it?

Reply via email to