Can I have both ISession and IStatelessSession side by side?

Consider a transaction model to see where, with help, IHttpModuleI open a transaction using the standard one ISession.

Now I have a page where I want to perform some batch operations. Since it IStatelessSessionis preferable for batch operations:

  • Is it possible to simultaneously open both ISession, and IStatelessSession? It is safe?
  • If 1. yes, can I use the same ITransaction?
  • If 2. not, should I lock and close ISessionand associated with it ITransaction, and then open for him IStatelessSessionand a new one ITransaction?
  • If 3. Yes, are there any pitfalls I should know about?

any ideas are welcome

+3
source share
1 answer
  • Yes and yes.
  • No, everyone will have their own transaction.
  • I would commit an ISession transaction, but leave ISession open.

I recommend not starting a transaction for every HTTP request. Instead, start and commit the transaction on the page when you have the changes to commit. This also improves exception handling because you can catch the exception on the page, rather than at the end of the request.

+2
source

Source: https://habr.com/ru/post/1751545/


All Articles