This repository adds an OGM functionality for csharp
MIT License
This repository is home to berrybeat's dotnet OGM (Object-Graph-Mapping) library for neo4j. It supports basic queries, create, update, connect/disconnect relations.
This library is available in nuget and can be installed with the following command:
dotnet add package Neo4j.Berries.OGM
Note: This is a dotnet 8 specific library.
The following snippet demonstrates the idea of how this library will be used with dependency injection.
public class MoviesController(ApplicationGraphContext graphContext): ControllerBase
{
[HttpPost]
public async Task Create(Movie request)
{
graphContext.Movies.Add(request);
await graphContext.SaveChangesAsync();
}
[HttpPost]
public async Task Update(Movie request)
{
await graphContext.Movies
.Match(x => x.Where(y => y.Id, request.Id))
.UpdateAsync(x => x.Set(request)) //Sets the whole object
}
}
The queries as you see are not supported with LINQ and instead you need to use the designed Eloquent. Also to use the library you need to add the following to your appsettings.json
.
{
"Neo4j": {
"Url": "<neo4j-address>",
"Username": "<neo4j-user>",
"Password": "<neo4j-password>",
"Database": "<neo4j-database-name>"
}
}
neo4j://localhost:7687
We welcome community enhancements and bug fixed. If you want to contribute to this repository please check How to contribute for more information
For more information about the library check Getting Started
For an example please check Example/MovieGraph
For checking the Neo4j Driver's manual please check The Neo4j .NET Driver Manual v5.18