简体   繁体   English

流利的Nhibernate和SQL脚本

[英]Fluent Nhibernate and sql script

I want to execute a script with variables in order to create a new database. 我想执行带有变量的脚本以创建新数据库。 At first, i tried with command line but i want to execute the script from another server but i have errors about access rights. 起初,我尝试使用命令行,但是我想从另一台服务器执行脚本,但是我有关于访问权限的错误。

Is it possible to execute a SQL script with fluent nhibernate in the application code? 是否可以在应用程序代码中流畅地使用nhibernate执行SQL脚本?

I've found an answer on that link but it doesn't execute the script, it loads queries. 我在该链接上找到了答案,但是它不执行脚本,而是加载查询。
link 链接

Thanks for help. 感谢帮助。

JUST a note: Fluent NHibernate is just a third party library for mapping. 只需注意:Fluent NHibernate只是用于映射的第三方库。 To execute script you need just NHibernate. 要执行脚本,您需要NHibernate。

And in fact, the answer you've found, is the answer. 实际上,您找到的答案就是答案。 The point of WRITE scripts is to call ExecuteUpdate() at the end WRITE脚本的重点是在最后调用ExecuteUpdate()

var query = session.CreateSQLQuery("your sql to string with INSERT, UPDATE...");
// that will execute that all
query.ExecuteUpdate();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM