/// <summary> /// Executes a SQL script. Includes support for executing /// scripts in batches using the GO keyword. /// </summary> public void ExecuteScript(DbTransaction tran, string script) { const string providerVariableName = "/*DNM:PROVIDER*/"; var batches = new ScriptSplitter(script); foreach (var batch in batches) { // replace the provider name token in the script var bakedBatch = batch.Replace(providerVariableName, _provider, StringComparison.OrdinalIgnoreCase); using (var cmd = CreateCommand()) { cmd.Transaction = tran; cmd.CommandText = bakedBatch; if (_commandTimeout.HasValue) { cmd.CommandTimeout = _commandTimeout.Value; } cmd.ExecuteNonQuery(); } } }
public SqlScriptReader(ScriptSplitter splitter) : base(splitter) { }
public SeparatorLineReader(ScriptSplitter splitter) : base(splitter) { }
protected ScriptReader(ScriptSplitter splitter) { Splitter = splitter; }