~donaldw/dbversion/verify-feature

« back to all changes in this revision

Viewing changes to src/DatabaseVersion/Tasks/Sql/ScriptTask.cs

  • Committer: Adam Connelly
  • Date: 2012-01-24 22:01:24 UTC
  • Revision ID: adam.rpconnelly@gmail.com-20120124220124-zi1dcqbt7bo8ie77
Updating ScriptTask so that it uses the current connection from the NHibernate session to create a command, and then uses that command to execute the script. Previously it was using ISession.CreateSQLQuery. The problem with CreateSQLQuery is that it parses the SQL text for parameters which can cause executing the script to fail.

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
        {
117
117
            MessageService.WriteDebugLine(String.Format("{0}", batch));
118
118
 
119
 
            var query = session.CreateSQLQuery(batch);
120
 
            query.ExecuteUpdate();
 
119
            using (var command = session.Connection.CreateCommand())
 
120
            {
 
121
                session.Transaction.Enlist(command);
 
122
                command.CommandText = batch;
 
123
                command.ExecuteNonQuery();
 
124
            }
121
125
        }
122
126
 
123
127
        public bool Equals(ScriptTask x, ScriptTask y)