Neo4jClient.Extension.Attributes
4.0.0-beta.1-12
See the version list below for details.
dotnet add package Neo4jClient.Extension.Attributes --version 4.0.0-beta.1-12
NuGet\Install-Package Neo4jClient.Extension.Attributes -Version 4.0.0-beta.1-12
<PackageReference Include="Neo4jClient.Extension.Attributes" Version="4.0.0-beta.1-12" />
<PackageVersion Include="Neo4jClient.Extension.Attributes" Version="4.0.0-beta.1-12" />
<PackageReference Include="Neo4jClient.Extension.Attributes" />
paket add Neo4jClient.Extension.Attributes --version 4.0.0-beta.1-12
#r "nuget: Neo4jClient.Extension.Attributes, 4.0.0-beta.1-12"
#:package Neo4jClient.Extension.Attributes@4.0.0-beta.1-12
#addin nuget:?package=Neo4jClient.Extension.Attributes&version=4.0.0-beta.1-12&prerelease
#tool nuget:?package=Neo4jClient.Extension.Attributes&version=4.0.0-beta.1-12&prerelease
Neo4jClient.Extension
A fluent API extension for Neo4jClient that simplifies building Cypher queries using strongly-typed C# objects.
Features
- Type-Safe Query Building - Create, match, and merge nodes and relationships using objects instead of writing Cypher strings
- Fluent Configuration - Configure entity metadata without cluttering domain models with attributes
- Relationship Modeling - Strongly-typed relationships with properties
- IntelliSense Support - Full IDE autocomplete for improved productivity
- Reduced Errors - Compile-time checking prevents property name typos and refactoring issues
Key Extension Methods
CreateEntity<T>- Create nodes from objectsMergeEntity<T>- Merge nodes with ON CREATE/ON MATCH supportMatchEntity<T>- Match nodes by propertiesCreateRelationship<T>- Create typed relationshipsMergeRelationship<T>- Merge relationshipsMatchRelationship<T>- Match relationships
Quick Start
Installation
# Install Neo4jClient
dotnet add package Neo4jClient
# Install Neo4jClient.Extension
dotnet add package Neo4jClient.Extension
Setup
using Neo4jClient;
using Neo4jClient.Extension.Cypher;
// Connect to Neo4j
var client = new BoltGraphClient(new Uri("bolt://localhost:7687"), "neo4j", "password");
await client.ConnectAsync();
// Configure your entities (do this once at startup)
FluentConfig.Config()
.With<Person>()
.Match(x => x.Id)
.Merge(x => x.Id)
.MergeOnCreate(p => p.DateCreated)
.Set();
Fluent Configuration
Configure entity metadata once at application startup without decorating your domain models:
FluentConfig.Config()
.With<Person>("SecretAgent")
.Match(x => x.Id)
.Merge(x => x.Id)
.MergeOnCreate(p => p.DateCreated)
.MergeOnMatchOrCreate(p => p.Name)
.MergeOnMatchOrCreate(p => p.Title)
.Set();
Configure relationships with properties:
FluentConfig.Config()
.With<HomeAddressRelationship>()
.MergeOnMatchOrCreate(hr => hr.DateEffective)
.Set();
Usage Examples
Create a Node
var person = new Person { Id = 1, Name = "John Doe" };
await client.Cypher
.CreateEntity(person, "p")
.ExecuteWithoutResultsAsync();
Create Nodes with Relationships
var person = new Person { Id = 1, Name = "John Doe" };
var address = new Address { Street = "123 Main St", City = "Austin" };
await client.Cypher
.CreateEntity(person, "p")
.CreateEntity(address, "a")
.CreateRelationship(new HomeAddressRelationship("p", "a"))
.ExecuteWithoutResultsAsync();
Merge Nodes
var person = new Person { Id = 1, Name = "John Doe", DateCreated = DateTime.UtcNow };
await client.Cypher
.MergeEntity(person) // Uses configured Merge properties
.MergeEntity(person.HomeAddress)
.MergeRelationship(new HomeAddressRelationship("person", "homeAddress"))
.ExecuteWithoutResultsAsync();
Alternative: Attribute Configuration
For those who prefer attributes, you can decorate your models directly:
[CypherLabel(Name = "Person")]
public class Person
{
[CypherMerge]
public Guid Id { get; set; }
[CypherMergeOnCreate]
public string Name { get; set; }
[CypherMergeOnMatchOrCreate]
public bool IsActive { get; set; }
}
Available Attributes:
CypherLabel- Custom node label (defaults to class name)CypherMatch- Used in MATCH clausesCypherMerge- Used in MERGE clausesCypherMergeOnCreate- Set only when creating (ON CREATE SET)CypherMergeOnMatch- Set only when matching (ON MATCH SET)
Note: Fluent configuration is recommended to keep domain models infrastructure-free.
Relationship Modeling
Define strongly-typed relationships by inheriting from BaseRelationship:
[CypherLabel(Name = "HOME_ADDRESS")]
public class HomeAddressRelationship : BaseRelationship
{
public HomeAddressRelationship(string fromKey, string toKey)
: base(fromKey, toKey) { }
public DateTime DateEffective { get; set; }
}
Development
Building
dotnet build Neo4jClient.Extension.sln
Running Tests
Unit Tests:
dotnet test test/Neo4jClient.Extension.UnitTest/
Integration Tests (requires Neo4j):
# Automated setup (recommended)
./run-tests-with-neo4j.sh # Linux/macOS
run-tests-with-neo4j.bat # Windows
# Manual setup
docker compose up -d neo4j
dotnet test --filter Integration
docker compose down
Packaging
powershell -f build.ps1 -packageVersion 1.0.0
Output: ./_output/ directory
Documentation
- CLAUDE.md - Comprehensive architecture documentation
- DOCKER-TESTING.md - Docker setup for integration tests
- Unit Tests - Usage examples
Requirements
- .NET 9.0 or later
- Neo4jClient 4.0.0+
- Neo4j 5.x (for integration tests)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the terms specified in the LICENSE file.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Neo4jClient (>= 4.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Neo4jClient.Extension.Attributes:
| Package | Downloads |
|---|---|
|
Neo4jClient.Extension
Package Description |
|
|
Neo4j.Tools.Write
This library aims at pushing a complex graph of entities into a Neo4j database by matching objects with nodes, and navigation properties with relations. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.0-beta.1-24 | 106 | 10/20/2025 |
| 4.0.3 | 166 | 10/20/2025 |
| 4.0.0-beta.1-17 | 106 | 10/20/2025 |
| 4.0.0-beta.1-12 | 105 | 10/20/2025 |
| 1.0.2 | 9,585 | 2/3/2017 |
| 1.0.1 | 7,905 | 2/21/2016 |
| 1.0.0 | 1,587 | 9/29/2015 |
| 0.1.3.1 | 1,472 | 8/23/2015 |
| 0.1.3 | 1,445 | 8/13/2015 |
| 0.1.0 | 4,938 | 2/19/2015 |