当前位置: 首页>>代码示例>>C#>>正文


C# IExecutionContext.AddSqlParameterToContext方法代码示例

本文整理汇总了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;
        }
开发者ID:vgrinin,项目名称:gin,代码行数:53,代码来源:CMRestoreSQLBackup.cs

示例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;
        }
开发者ID:vgrinin,项目名称:gin,代码行数:18,代码来源:CMCreateSQLBackup.cs

示例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;
        }
开发者ID:vgrinin,项目名称:gin,代码行数:10,代码来源:CMRestoreSQLBackup.cs


注:本文中的IExecutionContext.AddSqlParameterToContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。