-1

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?

I've found an answer on that link but it doesn't execute the script, it loads queries.
link

Thanks for help.

Community
  • 1
  • 1

1 Answers1

2

JUST a note: Fluent NHibernate is just a third party library for mapping. To execute script you need just NHibernate.

And in fact, the answer you've found, is the answer. The point of WRITE scripts is to call ExecuteUpdate() at the end

var query = session.CreateSQLQuery("your sql to string with INSERT, UPDATE...");
// that will execute that all
query.ExecuteUpdate();
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335