我怎样才能让NHibernate给我插入/更新生成的SQL而不是执行它? [英] How can i get NHibernate to give me the SQL it would generate for an insert / update instead of executing it?

查看:126
本文介绍了我怎样才能让NHibernate给我插入/更新生成的SQL而不是执行它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用NHibernate来映射一些非常简单的实体到三个表。

我的程序需要有一个模式,它输出要执行的SQL插入或更新这些表,以便SQL可以保存到一个脚本文件,以后手动执行。

这个类似于这个问题(它有一个很好的答案):我怎样才能有NHibernate只生成没有执行它的SQL?



只有这个问题是关于SELECT,我需要一样的,但插入/更新。
这也需要是动态的,因为它取决于用户选项。我的意思是,当我的程序:

  session.Save(entity); 

有时我需要这个来打db,有时我需要输出它执行的SQL。



这是否可能?

解决方案

不幸的是。

I'm using NHibernate to map some very simple entities to three tables.

My program needs to have a mode where it outputs the SQL it would execute to insert or update these tables, so that the SQL can be saved to a script file, to be later executed manually.

This is similar to this question (which has a very nice answer): How can I have NHibernate only generate the SQL without executing it?

Only that question is about SELECT, I need kind of the same but for INSERT / UPDATE. This also needs to be dynamic because it depends on a user option. I mean, when my program does:

        session.Save(entity);

sometimes I need that to hit the db and sometimes I need it to output the SQL it would execute.

Is this at all possible?

解决方案

This is not possible unfortunately.

这篇关于我怎样才能让NHibernate给我插入/更新生成的SQL而不是执行它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆