await using var conn = new NpgsqlConnection("Host=localhost;Username=test;Password=test"); await conn.OpenAsync(); await using var command = new NpgsqlCommand("SELECT * FROM data", conn); await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) { Console.WriteLine($"data: {reader.GetInt32(0)} -> {reader.GetString(1)}"); }
await using var conn = new NpgsqlConnection("Host=localhost;Username=test;Password=test"); await conn.OpenAsync(); foreach (var d in await conn.QueryAsync("SELECT * FROM data")) { Console.WriteLine($"Got some data: {d.Id} -> {d.Name}"); }