DotNetCore.GaussDB.DependencyInjection

Package Description


Keywords
GaussDB, ado, ado.net, database, dependency, di, injection, postgres, postgresql, sql
License
PostgreSQL
Install
Install-Package DotNetCore.GaussDB.DependencyInjection -Version 8.0.1

Documentation

DotNetCore.GaussDB - the .NET data provider for PostgreSQL

Member project of .NET Core Community nuget stats

Quickstart

Here's a basic code snippet to get you started:

using GaussDB;

var connString = "host={host};port={port};username={username};password={password};database={database}";

var dataSourceBuilder = new GaussDBDataSourceBuilder(connString);
var dataSource = dataSourceBuilder.Build();

var conn = await dataSource.OpenConnectionAsync();

// Insert some data
await using (var cmd = new GaussDBCommand("INSERT INTO data (some_field) VALUES (@p)", conn))
{
    cmd.Parameters.AddWithValue("p", "Hello world");
    await cmd.ExecuteNonQueryAsync();
}

// Retrieve all rows
await using (var cmd = new GaussDBCommand("SELECT some_field FROM data", conn))
await using (var reader = await cmd.ExecuteReaderAsync())
{
    while (await reader.ReadAsync())
        Console.WriteLine(reader.GetString(0));
}