本文整理匯總了C#中Npgsql.NpgsqlConnection.QueryAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# NpgsqlConnection.QueryAsync方法的具體用法?C# NpgsqlConnection.QueryAsync怎麽用?C# NpgsqlConnection.QueryAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Npgsql.NpgsqlConnection
的用法示例。
在下文中一共展示了NpgsqlConnection.QueryAsync方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetTests
public void GetTests()
{
using(var connection = new NpgsqlConnection(_appSettings.ConnectionString))
{
var rs = connection.QueryAsync("");
}
}
示例2: GetLatestStreamCreated
public static async Task<EventStream> GetLatestStreamCreated()
{
using (var connection = new NpgsqlConnection(GetConnectionStringBuilder()))
{
await connection
.OpenAsync()
.ConfigureAwait(false);
var query = await connection
.QueryAsync<EventStream>(SelectLatestStreamSql)
.ConfigureAwait(false);
return query.Any()
? query.Single()
: default(EventStream);
}
}
示例3: GetStreamEvents
public static async Task<IEnumerable<StoredEvent>> GetStreamEvents(Guid streamId)
{
using (var connection = new NpgsqlConnection(GetConnectionStringBuilder()))
{
await connection
.OpenAsync()
.ConfigureAwait(false);
var query = await connection
.QueryAsync<StoredEvent>(SelectStreamEventsSql)
.ConfigureAwait(false);
return query.ToList();
}
}