VOOZH about

URL: https://www.nuget.org/packages/Konnektr.Npgsql.Age/

⇱ NuGet Gallery | Konnektr.Npgsql.Age 2.0.0




Konnektr.Npgsql.Age 2.0.0

dotnet add package Konnektr.Npgsql.Age --version 2.0.0
 
 
NuGet\Install-Package Konnektr.Npgsql.Age -Version 2.0.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Konnektr.Npgsql.Age" Version="2.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Konnektr.Npgsql.Age" Version="2.0.0" />
 
Directory.Packages.props
<PackageReference Include="Konnektr.Npgsql.Age" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Konnektr.Npgsql.Age --version 2.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Konnektr.Npgsql.Age, 2.0.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Konnektr.Npgsql.Age@2.0.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Konnektr.Npgsql.Age&version=2.0.0
 
Install as a Cake Addin
#tool nuget:?package=Konnektr.Npgsql.Age&version=2.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Konnektr.Npgsql.Age

👁 Nuget

What is Apache AGE?

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#.

Quickstart

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);
 }
}

Using Cypher Parameters

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 a Dictionary

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}");
 }
}

Using a JSON String

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();
}

Complex Parameters

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 Values

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();
}

Acknowledgements

  • This project is a fork of Apache AGE.
  • The project relies heavily on the work of the Npgsql team.
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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Konnektr.Npgsql.Age:

Package Downloads
Konnektr.AgeDigitalTwins

Digital Twins SDK for Apache Age

GitHub repositories

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
Loading failed