Ambystech /oss

$ cd ~/oss/neo4j-repository

ambystechcom/Ambystech.Neo4j.Repository

neo4j.repository

Generic repository pattern for Neo4j

A lightweight, flexible repository pattern for Neo4j in .NET — simplifies graph data access and keeps your architecture clean and testable.

MIT C# neo4jrepository-patterndotnet
dotnet add package Ambystech.Neo4j.Repository
View on GitHub NuGet: Ambystech.Neo4j.Repository

A repository pattern implementation for Neo4j graph databases in .NET, enabling easy CRUD operations, relationship management and search functionality — so your graph data access stays clean, reusable and testable.

Packages

dotnet add package Ambystech.Neo4j.Repository
dotnet add package Ambystech.Neo4j.Repository.Contracts

Quick start

Configure your Neo4j connection in appsettings.json or user secrets:

{
  "Neo4j-Uri": "bolt://localhost:7687",
  "Neo4j-User": "neo4j",
  "Neo4j-Password": "password"
}

Register the services:

builder.Services.AddNeo4jRepository();
builder.Services.AddSingleton<INodeConverter<YourEntity>, YourEntityConverter>();
builder.Services.AddScoped<IBaseGraphRepository<YourEntity>, YourEntityRepository>();

Then use the repository:

var repository = serviceProvider.GetRequiredService<IBaseGraphRepository<YourEntity>>();
var entities = await repository.GetAllAsync();

Features

Example

The repository ships with a complete working example — a social network graph with Users, Posts, Likes and Dislikes — in the example/ directory.