本文整理汇总了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));
}
示例2: EmptyQueriesCauseFailedResult
public void EmptyQueriesCauseFailedResult()
{
var application = new SqlExecutor(m_SqlServerConfiguration);
application.SetUpDatabase(" ");
var result = application.ExecuteQuery("");
Assert.Equal("Query is empty", ExpectError(result));
}
示例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));
}
示例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));
}
示例5: ExecuteSqlOnBlankDatabase
private QueryResultTable ExecuteSqlOnBlankDatabase(string sql)
{
var application = new SqlExecutor(m_SqlServerConfiguration);
application.SetUpDatabase(" ");
return application.ExecuteQuery(sql).ExpectSuccess();
}
示例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;
}
}
}
示例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;
}
}