开发者

Can i have both ISession and IStatelessSession side by side?

Consider a transaction-per-view model where with an IHttpModule i open a transaction using a standard ISession.

Now, i have a page where i want to do some batch operations. Since IStatelessSession is preferred for batch operations:

  1. Can i have both ISession and IStatelessSession open at the same time? Is it safe?
  2. If 开发者_StackOverflow1. yes can i use the same ITransaction?
  3. If 2. no should i Commit & Close the ISession and its associated ITransaction and then open the IStatelessSession and a new ITransaction for it?
  4. If 3. yes are there any pitfalls i should be aware of?

any ideas are welcome


  1. Yes and yes.
  2. No, each will have its own transaction.
  3. I would commit the ISession's transaction but leave the ISession open.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜