![]() |
VOOZH | about |
dotnet add package Konnektr.Npgsql.Age --version 2.0.0
NuGet\Install-Package Konnektr.Npgsql.Age -Version 2.0.0
<PackageReference Include="Konnektr.Npgsql.Age" Version="2.0.0" />
<PackageVersion Include="Konnektr.Npgsql.Age" Version="2.0.0" />Directory.Packages.props
<PackageReference Include="Konnektr.Npgsql.Age" />Project file
paket add Konnektr.Npgsql.Age --version 2.0.0
#r "nuget: Konnektr.Npgsql.Age, 2.0.0"
#:package Konnektr.Npgsql.Age@2.0.0
#addin nuget:?package=Konnektr.Npgsql.Age&version=2.0.0Install as a Cake Addin
#tool nuget:?package=Konnektr.Npgsql.Age&version=2.0.0Install as a Cake Tool
Apache AGE is an open-source extension for PostgreSQL which provides it with the capabilities of a graph database. This package is a plugin for the Npgsql library which allows you to interact with Apache AGE from C#.
Here's a simple example to get you started:
using Npgsql;
using Npgsql.Age;
using Npgsql.Age.Types;
var connectionString = "Host=server;Port=5432;Username=user;Password=pass;Database=sample1";
var dataSourceBuilder = new NpgsqlDataSourceBuilder(connString);
await using var dataSource = dataSourceBuilder
.UseAge()
.Build();
// Create graph
await using (var cmd = dataSource.CreateGraphCommand("graph1"))
{
await cmd.ExecuteNonQueryAsync();
}
// Add vertices
await using (var cmd = dataSource.CreateCypherCommand("graph1", "CREATE (:Person {age: 23}), (:Person {age: 78})"))
{
await cmd.ExecuteNonQueryAsync();
}
// Retrieve vertices
await using (var cmd = dataSource.CreateCypherCommand(
"graph1", "MATCH (n:Person) RETURN n"))
await using (var reader = await cmd.ExecuteReaderAsync())
{
while (await reader.ReadAsync())
{
var agtypeResult = reader.GetValue<Agtype>(0);
Vertex person = agtypeResult.GetVertex();
Console.WriteLine(person);
}
}
You can pass parameters to your Cypher queries to avoid SQL injection and improve query reusability. Parameters are referenced in Cypher queries using the $ prefix (e.g., $name, $age).
using Npgsql;
using Npgsql.Age;
using Npgsql.Age.Types;
using System.Collections.Generic;
var parameters = new Dictionary<string, object?>
{
["name"] = "Alice",
["age"] = 30
};
await using (var cmd = dataSource.CreateCypherCommand(
"graph1",
"CREATE (p:Person {name: $name, age: $age}) RETURN p",
parameters))
await using (var reader = await cmd.ExecuteReaderAsync())
{
while (await reader.ReadAsync())
{
var agtypeResult = reader.GetValue<Agtype>(0);
Vertex person = agtypeResult.GetVertex();
Console.WriteLine($"Created: {person}");
}
}
You can also pass parameters as a JSON string:
string parametersJson = """{"name": "Bob", "age": 25}""";
await using (var cmd = dataSource.CreateCypherCommand(
"graph1",
"CREATE (p:Person {name: $name, age: $age}) RETURN p",
parametersJson))
{
await cmd.ExecuteNonQueryAsync();
}
Parameters can include nested objects and arrays:
var parameters = new Dictionary<string, object?>
{
["person"] = new Dictionary<string, object>
{
["name"] = "Charlie",
["age"] = 35,
["hobbies"] = new[] { "reading", "cycling" }
}
};
await using (var cmd = dataSource.CreateCypherCommand(
"graph1",
"CREATE (p:Person {name: $person.name, age: $person.age}) RETURN p",
parameters))
{
await cmd.ExecuteNonQueryAsync();
}
Null parameter values are supported:
var parameters = new Dictionary<string, object?>
{
["name"] = "David",
["email"] = null // Optional property
};
await using (var cmd = dataSource.CreateCypherCommand(
"graph1",
"CREATE (p:Person {name: $name}) RETURN p",
parameters))
{
await cmd.ExecuteNonQueryAsync();
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Konnektr.Npgsql.Age:
| Package | Downloads |
|---|---|
|
Konnektr.AgeDigitalTwins
Digital Twins SDK for Apache Age |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 777 | 5/28/2026 |
| 1.3.0 | 228 | 5/14/2026 |
| 1.2.1 | 11,624 | 12/16/2025 |
| 1.2.0 | 302 | 12/16/2025 |
| 1.1.0 | 1,219 | 10/22/2025 |
| 1.0.9 | 207 | 10/22/2025 |
| 1.0.8 | 536 | 9/3/2025 |
| 1.0.7 | 326 | 8/11/2025 |
| 1.0.6 | 688 | 7/16/2025 |
| 1.0.5 | 1,162 | 4/14/2025 |
| 1.0.4 | 844 | 2/11/2025 |
| 1.0.3 | 397 | 1/6/2025 |
| 1.0.2 | 221 | 1/6/2025 |
| 1.0.1 | 182 | 1/6/2025 |
| 0.4.0 | 727 | 12/6/2024 |
| 0.3.9 | 212 | 12/5/2024 |
| 0.3.8 | 190 | 12/5/2024 |
| 0.3.7 | 223 | 12/3/2024 |
| 0.3.6 | 178 | 12/3/2024 |
| 0.3.5 | 173 | 12/3/2024 |