本文整理汇总了C#中IExecutionContext.AddSqlParameterToContext方法的典型用法代码示例。如果您正苦于以下问题:C# IExecutionContext.AddSqlParameterToContext方法的具体用法?C# IExecutionContext.AddSqlParameterToContext怎么用?C# IExecutionContext.AddSqlParameterToContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExecutionContext
的用法示例。
在下文中一共展示了IExecutionContext.AddSqlParameterToContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitRestoreParameters
private List<SqlParameterClass> InitRestoreParameters(IExecutionContext context, string resultSetCtxName)
{
List<SqlParameterClass> parameters = new List<SqlParameterClass>();
DataTable fileList = (DataTable)context.GetResult(resultSetCtxName);
var files = fileList.AsEnumerable();
var rows = files.AsEnumerable();
var rowDataFile = rows.FirstOrDefault(r => (string)r["Type"] == "D");
if (rowDataFile == null)
{
throw new Exception("Бэкап не содержит файла MDF базы данных");
}
var rowLogFile = rows.FirstOrDefault(r => (string)r["Type"] == "L");
if (rowLogFile == null)
{
throw new Exception("Бэкап не содержит файла LDF журнала транзакций");
}
string ldfFileLogicalName = (string)rowLogFile["LogicalName"];
string mdfFileLogicalName = (string)rowDataFile["LogicalName"];
string ldfFilePhysicalName = (string)rowLogFile["PhysicalName"];
string mdfFilePhysicalName = (string)rowDataFile["PhysicalName"];
if (DataBaseFullPath != null)
{
string mdfFileOnlyName = Path.GetFileName(mdfFilePhysicalName);
string ldfFileOnlyName = Path.GetFileName(ldfFilePhysicalName);
DataBaseFullPath = context.GetStringFrom(DataBaseFullPath);
mdfFilePhysicalName = Path.Combine(DataBaseFullPath, mdfFileOnlyName);
ldfFilePhysicalName = Path.Combine(DataBaseFullPath, ldfFileOnlyName);
}
SqlParameterClass p = context.AddSqlParameterToContext("BASENAME", DatabaseName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
parameters.Add(p);
string absoluteSourcePath = context.GetStringFrom(BackupFilePath);
p = context.AddSqlParameterToContext("FULLNAME", absoluteSourcePath, SqlDbType.VarChar, 1024, ParameterDirection.Input);
parameters.Add(p);
p = context.AddSqlParameterToContext("MDFLOGICALNAME", mdfFileLogicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
parameters.Add(p);
p = context.AddSqlParameterToContext("MDFFILEPATH", mdfFilePhysicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
parameters.Add(p);
p = context.AddSqlParameterToContext("LDFLOGICALNAME", ldfFileLogicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
parameters.Add(p);
p = context.AddSqlParameterToContext("LDFFILEPATH", ldfFilePhysicalName, SqlDbType.VarChar, 1024, ParameterDirection.Input);
parameters.Add(p);
return parameters;
}
示例2: InitParameters
private List<SqlParameterClass> InitParameters(IExecutionContext context)
{
List<SqlParameterClass> parameters = new List<SqlParameterClass>();
string absoluteDatabaseName = context.GetStringFrom(DatabaseName);
context.Log.AddLogInformation("DatabaseName = '" + absoluteDatabaseName + "'");
SqlParameterClass p = context.AddSqlParameterToContext("BASENAME", absoluteDatabaseName, SqlDbType.VarChar, 255, ParameterDirection.Input);
parameters.Add(p);
string absoluteBackupFilePath = context.GetStringFrom(BackupFilePath);
context.Log.AddLogInformation("BackupFilePath = '" + absoluteBackupFilePath + "'");
string backupName = Path.GetFileNameWithoutExtension(absoluteBackupFilePath);
p = context.AddSqlParameterToContext("NAME", backupName, SqlDbType.VarChar, 255, ParameterDirection.Input);
parameters.Add(p);
p = context.AddSqlParameterToContext("FULLNAME", absoluteBackupFilePath, SqlDbType.VarChar, 255, ParameterDirection.Input);
parameters.Add(p);
return parameters;
}
示例3: InitFilelistParameters
private List<SqlParameterClass> InitFilelistParameters(IExecutionContext context)
{
List<SqlParameterClass> parameters = new List<SqlParameterClass>();
string absoluteBackupFilePath = context.GetStringFrom(BackupFilePath);
SqlParameterClass p = context.AddSqlParameterToContext("FULLNAME", absoluteBackupFilePath, SqlDbType.VarChar, 1024, ParameterDirection.Input);
parameters.Add(p);
return parameters;
}