public static IReadOnlyCollection<Tuple<string, string>> GetLogicalAndPhysicalNamesFromBackupFile(DatabaseConnectionInfo db, string backupFile) { using (var f = new SqlCommandFactory(ToConnectionString(db), null)) using (var cmd = f.CreateCommand(null)) { cmd.CommandText = "RESTORE FILELISTONLY FROM DISK = @path"; cmd.Parameters.Add("@path", SqlDbType.NVarChar).Value = backupFile; var result = new List<Tuple<string, string>>(); using (var r = cmd.ExecuteReader()) { while (r.Read()) { var logicalName = (string)r["LogicalName"]; var physicalName = (string)r["PhysicalName"]; result.Add(Tuple.Create(logicalName, physicalName)); } } return result; } }
public SqlCommandExecutionResult(DatabaseConnectionInfo db, string name, string script, IEnumerable<SqlParameter> parameters) { mFactory = new SqlCommandFactory(ToConnectionString(db), OnMessage); mCommand = mFactory.CreateCommand(name); mCommand.CommandText = script; mOutput = new BlockingCollection<ProcessOutputLine>(); foreach (var sqlParameter in parameters) { mCommand.Parameters.Add(sqlParameter); } }
public ConnectionMessageHandler(SqlCommandFactory factory, object context) { mFactory = factory; mContext = context; }