3

I am trying to create a type of recorded data transaction that I can replay on a different database.

For example I am capturing an order into a system, when I save that I want to be able to "export" a sql script that I can run on another database to create the same order.

I am using NHibernate and I am trying to catch the sql query string for the save operation to save to a file, but with no success.

adriaanp
  • 2,064
  • 2
  • 22
  • 40

1 Answers1

1

Checkout this question: Get executed SQL from nHibernate

I'm not sure if there is a better alternative like an event listener, if not, the IInterceptor approach seems to be the best.

Community
  • 1
  • 1
Ariel Popovsky
  • 4,787
  • 2
  • 28
  • 30
  • This does work but just not quite as the values is not passed into the Interceptor. I think the best way is to create a log4net appender and catch NHibernate.SQL logger's output there. – adriaanp Mar 16 '10 at 10:34
  • Not a bad idea, apparently that's how NHprof (the NH profiler) gets all the query information including parameters. BTW, you could try using NHibernate with both databases, there are some questions here and many blog posts on that subject. – Ariel Popovsky Mar 16 '10 at 14:15