PureQL.CSharp.Model.Graph.Neo4j.Updating 0.1.0-preview.0.1.0

This is a prerelease version of PureQL.CSharp.Model.Graph.Neo4j.Updating.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package PureQL.CSharp.Model.Graph.Neo4j.Updating --version 0.1.0-preview.0.1.0
                    
NuGet\Install-Package PureQL.CSharp.Model.Graph.Neo4j.Updating -Version 0.1.0-preview.0.1.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="PureQL.CSharp.Model.Graph.Neo4j.Updating" Version="0.1.0-preview.0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PureQL.CSharp.Model.Graph.Neo4j.Updating" Version="0.1.0-preview.0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="PureQL.CSharp.Model.Graph.Neo4j.Updating" />
                    
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 PureQL.CSharp.Model.Graph.Neo4j.Updating --version 0.1.0-preview.0.1.0
                    
#r "nuget: PureQL.CSharp.Model.Graph.Neo4j.Updating, 0.1.0-preview.0.1.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 PureQL.CSharp.Model.Graph.Neo4j.Updating@0.1.0-preview.0.1.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=PureQL.CSharp.Model.Graph.Neo4j.Updating&version=0.1.0-preview.0.1.0&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PureQL.CSharp.Model.Graph.Neo4j.Updating&version=0.1.0-preview.0.1.0&prerelease
                    
Install as a Cake Tool

PureQL.CSharp.Model.Graph.Neo4j.Updating

Replaces a PureQL query stored in Neo4j, keeping its id.

.NET build & test Build and Deploy NuGet License: MIT

Overview

PureQL.CSharp.Model.Graph.Neo4j.Updating is the updating package of the PureQL.CSharp.Model.Graph family. It replaces the graph stored under a query's id with the graph of a new query by composing the Deletion and Insertion packages on one runner.

Public API

Namespace PureQL.CSharp.Model.Graph.Neo4j.Updating:

Name Description
ReplacedQuery sealed record ReplacedQuery(IAsyncQueryRunner Runner, StoredQuery Query); ApplyAsync deletes the stored query and writes the new one on a session or transaction you own
ReplacedQueryOf sealed record ReplacedQueryOf(INeo4jStoredQueries Store, StoredQuery Query); ApplyAsync opens a session on the store and replaces the query in one managed write transaction

Usage

using Neo4j.Driver;
using PureQL.CSharp.Model;
using PureQL.CSharp.Model.Graph.Neo4j.Abstractions;
using PureQL.CSharp.Model.Graph.Neo4j.Updating;

await using IDriver driver = GraphDatabase.Driver(
    "neo4j://localhost:7687",
    AuthTokens.Basic("neo4j", "password")
);
INeo4jStoredQueries store = new Neo4jStoredQueries(driver);
Guid id = /* the id of a stored query */;
PureQLQuery edited = /* the query that replaces it */;

// In a transaction of its own:
await new ReplacedQueryOf(store, new StoredQuery(id, edited)).ApplyAsync();

// Or together with other operations, in your transaction:
await using IAsyncSession session = driver.AsyncSession(
    builder => builder.WithDatabase(store.Database)
);
await session.ExecuteWriteAsync(
    async transaction =>
    {
        await new ReplacedQuery(transaction, new StoredQuery(id, edited)).ApplyAsync();
        // ...other operations on the same transaction
    }
);

How a query is replaced

ReplacedQuery runs two statements on its runner, in order:

  1. DeletedQuery(Runner, Query.Id) — MATCH (n:Node {queryId: $id}) DETACH DELETE n removes every node of the stored graph and every relationship attached to them.
  2. InsertedQuery(Runner, Query) — writes the graph of the new query under the same id in one statement.

The query keeps its id, so the Query.id uniqueness constraint (pureql_query_id, created by the Creation package) is never hit: the old root is deleted before the new one is written.

Replacing an id that is not stored simply inserts the query: deleting what is not stored is a no-op.

Transactions

  • ReplacedQueryOf runs both statements in one managed write transaction (ExecuteWriteAsync). If the insertion fails — the query cannot be mapped to a graph (GraphMappingException), the server rejects the statement (ClientException), or the token is cancelled — the transaction rolls back and the stored query is left as it was. The exception is not wrapped.
  • With ReplacedQuery, the transaction boundary is yours. On an IAsyncTransaction both statements commit or roll back together with the rest of your work. On an IAsyncSession each statement commits on its own, so a failed insertion leaves the query deleted; pass a transaction unless that is what you want.

Cancellation

Neo4j.Driver 6.x takes no cancellation token for a running statement, so ApplyAsync checks its token before each statement it sends (and ReplacedQueryOf also before it opens the session).

Design Principles

  • Sealed records with their dependencies in the constructor; no static services
  • Composable — ReplacedQuery runs on any IAsyncQueryRunner, a session or a transaction, and is itself built from the Deletion and Insertion packages
  • AOT-compatible — IsAotCompatible=true; no reflection

Dependencies

Target Frameworks

  • .NET 11

Installation

dotnet add package PureQL.CSharp.Model.Graph.Neo4j.Updating
Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-preview.0.2.0 82 11/11/2026
0.1.0-preview.0.1.0 68 11/9/2026