Reputation: 65
Quick question.. In a function that checks if a certain Terminal Id is available, is it okay for me to do it as below?
using (var tx = session.BeginTransaction())
{
return ((new TerminalDAO(sm.Session)).Get(tid) == null) ? true : false;
}
Or is it advisable to do it with the Commit()?
Terminal terminal = null;
using (var tx = session.BeginTransaction())
{
terminal = (new TerminalDAO(session)).Get(tid);
tx.Commit();
}
return (terminal == null) ? true : false;
Upvotes: 4
Views: 239
Reputation: 123901
For readonly operations - I would firstly appreciate you, that you did included transaction even for readonly operation - and also suggest to use a rollback and in fact the explicit rollback.
Please check these:
My reason for explicit Rollback()
would be:
Upvotes: 5