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


C# SqlExecutor.ExecuteQuery方法代码示例

本文整理汇总了C#中SqlExecutor.ExecuteQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SqlExecutor.ExecuteQuery方法的具体用法?C# SqlExecutor.ExecuteQuery怎么用?C# SqlExecutor.ExecuteQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqlExecutor的用法示例。


在下文中一共展示了SqlExecutor.ExecuteQuery方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BadlyFormedQueriesCauseFailedResult

        public void BadlyFormedQueriesCauseFailedResult()
        {
            var application = new SqlExecutor(m_SqlServerConfiguration);
            application.SetUpDatabase(" ");
            var result = application.ExecuteQuery("SELECTEROO");

            Assert.Equal("Could not find stored procedure 'SELECTEROO'.", ExpectError(result));
        }
开发者ID:modulexcite,项目名称:learnsomesql.com,代码行数:8,代码来源:SqlExecutorTests.cs

示例2: EmptyQueriesCauseFailedResult

 public void EmptyQueriesCauseFailedResult()
 {
     var application = new SqlExecutor(m_SqlServerConfiguration);
     application.SetUpDatabase(" ");
     var result = application.ExecuteQuery("");
     
     Assert.Equal("Query is empty", ExpectError(result));
 }
开发者ID:modulexcite,项目名称:learnsomesql.com,代码行数:8,代码来源:SqlExecutorTests.cs

示例3: SetUpRunsCreationSql

        public void SetUpRunsCreationSql()
        {
            var creationSql = @"
                CREATE TABLE JustTesting (
	                Id INT IDENTITY NOT NULL,
	                Answer INT NOT null
                )

                INSERT INTO JustTesting (Answer) VALUES (42)
            ";

            var application = new SqlExecutor(m_SqlServerConfiguration);
            application.SetUpDatabase(creationSql);
            var result = application.ExecuteQuery("SELECT Answer FROM JustTesting").ExpectSuccess();
            Assert.Equal(42, result.Rows[0].ValueAtIndex<int>(0));
        }
开发者ID:modulexcite,项目名称:learnsomesql.com,代码行数:16,代码来源:SqlExecutorTests.cs

示例4: AssertDisplayValue

        private void AssertDisplayValue(string sqlType, string sqlValue, string expectedDisplayValue)
        {
            var creationSqlTemplate = @"
                CREATE TABLE JustTesting (
	                Id INT IDENTITY NOT NULL,
	                Answer {0} NOT null
                )

                INSERT INTO JustTesting (Answer) VALUES ({1})
            ";
            var creationSql = string.Format(creationSqlTemplate, sqlType, sqlValue);

            var application = new SqlExecutor(m_SqlServerConfiguration);
            application.SetUpDatabase(creationSql);
            var result = application.ExecuteQuery("SELECT Answer FROM JustTesting").ExpectSuccess();
            Assert.Equal(expectedDisplayValue, result.Rows[0].DisplayValueAtIndex(0));
        }
开发者ID:modulexcite,项目名称:learnsomesql.com,代码行数:17,代码来源:SqlExecutorTests.cs

示例5: ExecuteSqlOnBlankDatabase

 private QueryResultTable ExecuteSqlOnBlankDatabase(string sql)
 {
     var application = new SqlExecutor(m_SqlServerConfiguration);
     application.SetUpDatabase(" ");
     return application.ExecuteQuery(sql).ExpectSuccess();
 }
开发者ID:modulexcite,项目名称:learnsomesql.com,代码行数:6,代码来源:SqlExecutorTests.cs

示例6: GetMigrationsRunInDb

        public IEnumerable<Migration> GetMigrationsRunInDb(DirectoryInfo dbScriptsPath, Server dbServer, string dbname)
        {
            var migrationSqlFilesInVcs = GetSqlSriptsIn(dbScriptsPath.FullName);
            if (!migrationSqlFilesInVcs.Any())
                yield break;

            CheckIfDatabaseChangeLogTableExists(dbServer.Databases[dbname]);

            var sqlExecutor = new SqlExecutor(dbServer);

            //FIXME: use hashes, not filenames!
            using (SqlDataReader reader = sqlExecutor.ExecuteQuery(String.Format(
                "SELECT FileName,Applied FROM {0}", DatabaseChangeLogTableName), dbname)){
                while (reader.Read())
                {
                    var migration = new Migration();
                    var filename = (string) reader["FileName"];
                    if (!filename.EndsWith(SqlSuffix))
                        throw new Exception(
                            String.Format("Expecting filename ending with '{0}' but found '{1}' in {2}'s {3} table",
                                SqlSuffix, filename, dbServer.Name, DatabaseChangeLogTableName));
                    migration.FileNameWithoutExtension = filename.Substring(0, filename.Length - SqlSuffix.Length);
                    migration.AppliedDate = (DateTime) reader["Applied"];
                    yield return migration;
                }
            }
        }
开发者ID:7digital,项目名称:DatabaseMigraine,代码行数:27,代码来源:MigrationManager.cs

示例7: MigrationAlreadyRun

 private static bool MigrationAlreadyRun(SqlExecutor executor, string hash, string dbname)
 {
     string sqlHashChecker = String.Format("SELECT 'x' FROM {0} WHERE Hash = '{1}'", DatabaseChangeLogTableName, hash.Replace("'", "''"));
     using (var result = executor.ExecuteQuery(sqlHashChecker, dbname))
     {
         return result.HasRows;
     }
 }
开发者ID:7digital,项目名称:DatabaseMigraine,代码行数:8,代码来源:MigrationManager.cs


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