Reputation: 689
I have in DB the mapped table with id 7, field Taex with value "qwe"
in this code:
var fooObj = Foo.GetById(7);
fooObj.Taex = "abc";
using (new TransactionScope(OnDispose.Rollback))
{
var originalFooObj = Foo.GetById(7);
// how can i do to get real original object from database into a transaction
bool areEquals = fooObj.Taex == originalFooObj.Taex; // are equals
// because nhibernate gets the cached object.
}
i need the db original data into the transaction, how can i do ?
Upvotes: 0
Views: 214
Reputation: 15217
NHibernate has Refresh
method. You can use it to force NH to reload entity from DB
Upvotes: 1
Reputation: 67296
Don't you have it already:
var fooObj = Foo.GetById(7);
var tempTaex = fooObj.Taex; //**get the original value
fooObj.Taex = "abc";
using (new TransactionScope(OnDispose.Rollback))
{
var originalFooObj = Foo.GetById(7);
// how can i do to get real original object from database into a transaction
bool areEquals = fooObj.Taex == tempTaex; //**use it
// because nhibernate gets the cached object.
}
Upvotes: 0