PureQL.CSharp.Model.Graph.Neo4j.Querying 0.1.0-preview.0.2.0

This is a prerelease version of PureQL.CSharp.Model.Graph.Neo4j.Querying.
dotnet add package PureQL.CSharp.Model.Graph.Neo4j.Querying --version 0.1.0-preview.0.2.0
                    
NuGet\Install-Package PureQL.CSharp.Model.Graph.Neo4j.Querying -Version 0.1.0-preview.0.2.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.Querying" Version="0.1.0-preview.0.2.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.Querying" Version="0.1.0-preview.0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="PureQL.CSharp.Model.Graph.Neo4j.Querying" />
                    
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.Querying --version 0.1.0-preview.0.2.0
                    
#r "nuget: PureQL.CSharp.Model.Graph.Neo4j.Querying, 0.1.0-preview.0.2.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.Querying@0.1.0-preview.0.2.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.Querying&version=0.1.0-preview.0.2.0&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PureQL.CSharp.Model.Graph.Neo4j.Querying&version=0.1.0-preview.0.2.0&prerelease
                    
Install as a Cake Tool

PureQL.CSharp.Model.Graph.Neo4j.Querying

Reads PureQL queries stored as property graphs in Neo4j back into PureQLQuery values.

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

Overview

PureQL.CSharp.Model.Graph.Neo4j.Querying is the read operation package of the PureQL.CSharp.Model.Graph family: it reads the query graphs that PureQL.CSharp.Model.Graph.Neo4j.Insertion writes back into StoredQuery values and answers structural lookups over them.

Public API

Namespace PureQL.CSharp.Model.Graph.Neo4j.Querying. Every reader runs on an IAsyncQueryRunner (an IAsyncSession, whose RunAsync runs an auto-commit query, or an IAsyncTransaction), so reads compose with the other operation packages inside one transaction. Each has an ...Of twin over INeo4jStoredQueries that opens a read session on Store.Driver against Store.Database and runs auto-commit queries.

Reader Twin Result
QueryById(IAsyncQueryRunner Runner, Guid Id) QueryByIdOf(INeo4jStoredQueries Store, Guid Id) Task<StoredQuery?> ValueAsync(ct): the query, or null when no query has the id
QueriesByIds(IAsyncQueryRunner Runner, IReadOnlyCollection<Guid> Ids) QueriesByIdsOf(INeo4jStoredQueries Store, IReadOnlyCollection<Guid> Ids) IAsyncEnumerable<StoredQuery> Values(ct): the queries that exist, each once, in ascending order of id; missing ids are skipped
AllQueries(IAsyncQueryRunner Runner) AllQueriesOf(INeo4jStoredQueries Store) IAsyncEnumerable<StoredQuery> Values(ct): every stored query, streamed in ascending order of id
QueriesReferencingField(IAsyncQueryRunner Runner, string Source, string Field) QueriesReferencingFieldOf(INeo4jStoredQueries Store, string Source, string Field) Task<IReadOnlyList<Guid>> ValueAsync(ct): the ids of the queries with a node referencing the field of the source
QueriesDeclaringParameter(IAsyncQueryRunner Runner, string Param) QueriesDeclaringParameterOf(INeo4jStoredQueries Store, string Param) Task<IReadOnlyList<Guid>> ValueAsync(ct): the ids of the queries using the parameter

A stored graph that does not map back to a query throws GraphMappingException from PureQL.CSharp.Model.Graph.

The statements are public too, each a record whose Query Value is a Neo4j.Driver.Query (Cypher text and parameters):

Statement Cypher
QueryByIdStatement(Guid Id) MATCH (n:Node {queryId: $id}) RETURN n, [(n)-[r]->(m) \| [type(r), r.position, elementId(m)]] AS out
QueriesByIdsStatement(IReadOnlyCollection<Guid> Ids) MATCH (n:Node) WHERE n.queryId IN $ids RETURN n.queryId AS queryId, n, [(n)-[r]->(m) \| [type(r), r.position, elementId(m)]] AS out ORDER BY queryId
QueryIdsPageStatement(Guid? After, int Size) MATCH (q:Query) WHERE q.id > $after RETURN q.id AS id ORDER BY id LIMIT $size
QueriesReferencingFieldStatement(string Source, string Field) MATCH (n:Node) WHERE n.field = $field AND n.source = $source RETURN DISTINCT n.queryId AS queryId
QueriesDeclaringParameterStatement(string Param) MATCH (n:Node) WHERE n.param = $param RETURN DISTINCT n.queryId AS queryId

The lookups and the reads by id are served by the Node(queryId), Node(field, source) and Node(param) indexes and the Query.id constraint that PureQL.CSharp.Model.Graph.Neo4j.Creation creates; they also work without them, by scanning.

How a query is read back

The rows of a query's nodes become ReadNodes of PureQL.CSharp.Model.Graph: the label is the node's record label (the one that is neither Node nor Query), the properties are converted to the graph's store-neutral representation (integers stay long; a list becomes a string[], long[] or bool[] by its elements, an empty list a string[]; a null counts as absent), and the children are wired by element id, grouped by relationship type and ordered by position. QueryGraphs.Read then reads the node labelled Query. QueriesByIds reads all its queries with one statement and yields each query as soon as its rows are read; AllQueries pages through the ids of the Query nodes 50 at a time, so memory holds one page of ids and one query however many queries are stored.

Usage

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

await using IDriver driver = GraphDatabase.Driver(
    "neo4j://localhost:7687",
    AuthTokens.Basic("neo4j", "password")
);
INeo4jStoredQueries store = new Neo4jStoredQueries(driver);
Guid queryId = /* the id a visualization holds */;
IReadOnlyCollection<Guid> queryIds = /* the ids a dashboard's visualizations hold */;

// One query by the id a visualization holds:
StoredQuery? query = await new QueryByIdOf(store, queryId).ValueAsync();

// The queries of a dashboard, in one statement:
await foreach (StoredQuery stored in new QueriesByIdsOf(store, queryIds).Values())
{
    Console.WriteLine($"{stored.Id}: {stored.Query}");
}

// Which queries break if the orders.amount field is renamed?
IReadOnlyList<Guid> affected = await new QueriesReferencingFieldOf(
    store,
    "orders",
    "amount"
).ValueAsync();

// Or read inside a transaction of your own:
await using IAsyncSession session = driver.AsyncSession(
    builder => builder.WithDatabase(store.Database)
);
StoredQuery? same = await session.ExecuteReadAsync(
    transaction => new QueryById(transaction, queryId).ValueAsync()
);

Design Principles

  • One statement per read — a query, a set of queries and a lookup each take one round trip; AllQueries takes two per page
  • Composable — readers run on any IAsyncQueryRunner, so they share a transaction with writes of the sibling packages
  • AOT-compatible — IsAotCompatible=true, no reflection

Installation

dotnet add package PureQL.CSharp.Model.Graph.Neo4j.Querying

Dependencies

Target Frameworks

  • .NET 11
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 81 11/11/2026
0.1.0-preview.0.1.0 73 11/9/2026