PureQL.CSharp.Model.Graph.Neo4j.Updating
0.1.0-preview.0.1.0
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
<PackageReference Include="PureQL.CSharp.Model.Graph.Neo4j.Updating" Version="0.1.0-preview.0.1.0" />
<PackageVersion Include="PureQL.CSharp.Model.Graph.Neo4j.Updating" Version="0.1.0-preview.0.1.0" />
<PackageReference Include="PureQL.CSharp.Model.Graph.Neo4j.Updating" />
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"
#:package PureQL.CSharp.Model.Graph.Neo4j.Updating@0.1.0-preview.0.1.0
#addin nuget:?package=PureQL.CSharp.Model.Graph.Neo4j.Updating&version=0.1.0-preview.0.1.0&prerelease
#tool nuget:?package=PureQL.CSharp.Model.Graph.Neo4j.Updating&version=0.1.0-preview.0.1.0&prerelease
PureQL.CSharp.Model.Graph.Neo4j.Updating
Replaces a PureQL query stored in Neo4j, keeping its id.
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:
DeletedQuery(Runner, Query.Id)—MATCH (n:Node {queryId: $id}) DETACH DELETE nremoves every node of the stored graph and every relationship attached to them.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
ReplacedQueryOfruns 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 anIAsyncTransactionboth statements commit or roll back together with the rest of your work. On anIAsyncSessioneach 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 —
ReplacedQueryruns on anyIAsyncQueryRunner, a session or a transaction, and is itself built from the Deletion and Insertion packages - AOT-compatible —
IsAotCompatible=true; no reflection
Dependencies
PureQL.CSharp.Model.Graph.Neo4j.Deletion0.1.0-preview.0.1.0—DeletedQueryPureQL.CSharp.Model.Graph.Neo4j.Insertion0.1.0-preview.0.1.0—InsertedQueryPureQL.CSharp.Model.Graph0.1.0-preview.1.0.0—QueryGraphs,GraphMappingExceptionPureQL.CSharp.Model.Graph.Neo4j.Abstractions0.1.0-preview.1.0.0—INeo4jStoredQueries,StoredQueryNeo4j.Driver6.5.1
Target Frameworks
- .NET 11
Installation
dotnet add package PureQL.CSharp.Model.Graph.Neo4j.Updating
Related packages
PureQL.CSharp.Model.Graph— maps aPureQLQueryto a property graph and back, without a driverPureQL.CSharp.Model.Graph.Neo4j.Abstractions— the stored-queries contract the Neo4j packages sharePureQL.CSharp.Model.Graph.Neo4j.Creation— constraints and indexesPureQL.CSharp.Model.Graph.Neo4j.Insertion— writes queriesPureQL.CSharp.Model.Graph.Neo4j.Querying— reads queries backPureQL.CSharp.Model.Graph.Neo4j.Deletion— deletes queriesPureQL.CSharp.Model.Graph.Neo4j.Existence— checks the schema and queries existPureQL.CSharp.Model.Graph.Neo4j.Destruction— drops the schema and every stored queryPureQL.CSharp.Model.Graph.Neo4j.Migration— migrates stored graphs between model versionsPureQL.CSharp.Model.Serialization— JSON for the same model
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Neo4j.Driver (>= 6.5.1)
- PureQL.CSharp.Model.Graph (>= 0.1.0-preview.1.0.0)
- PureQL.CSharp.Model.Graph.Neo4j.Abstractions (>= 0.1.0-preview.1.0.0)
- PureQL.CSharp.Model.Graph.Neo4j.Deletion (>= 0.1.0-preview.0.1.0)
- PureQL.CSharp.Model.Graph.Neo4j.Insertion (>= 0.1.0-preview.0.1.0)
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 |