Does this (not CRUD, but only Read) code require me to write transaction management?
ICriteria criteria = SessionFactory.GetCurrentSession().CreateCriteria(EntityType);
criteria.List<BaseEntity>();
Does this (not CRUD, but only Read) code require me to write transaction management?
ICriteria criteria = SessionFactory.GetCurrentSession().CreateCriteria(EntityType);
criteria.List<BaseEntity>();
I cannot say that I do it always, But I would say that this question is pretty reasonable. As you can Transactions for read-only DB access? what we can get is:
Transaction are required for read-only operations if you want to set a specific timeout for queries other than the default timeout, or if you want to change the isolation level.
And as mentioned here: NHibernate Transactions on Reads (small extract)
Even if we are only reading data, we want to use a transaction, because using a transaction ensure that we get a consistent result from the database.
So, in general, if you have common way (e.g. Web request handling with AOP) it could be useful
No, why would you need a transaction for read only operations?
Transactions are only needed if you want to rollback multiple write/update/delete operations.