Formally known as Neo4jMapper
, Neo4j.Mapper is a .NET6.0 library to simplify mapping of cypher values onto your models.
var cursor = await Session.RunAsync(@"
MATCH (person:Person {name: 'Cuba Gooding Jr.'})-[:ACTED_IN]->(movie:Movie)
RETURN person, COLLECT(movie) AS movies");
var actor = await cursor
.MapSingleAsync((Person person, IEnumerable<Movie> movies) =>
{
person.MoviesActedIn = movies;
return person;
});
Assert.AreEqual("Cuba Gooding Jr.", actor.name);
Assert.AreEqual(1968, actor.born);
Assert.AreEqual(4, actor.MoviesActedIn.Count());
- Simple Map API which extends Neo4j Driver's IRecord to greatly simplify the extraction and projection of cypher values onto your entity models.
- Works asynchronously via IStatementResultCursor methods.
- Automatic mapping of node Ids to your entity models, and GetNode & SetNode helper methods to simplify writing CRUD methods.
- Custom converters to facilitate conversion between Neo4j Driver's temporal data types such as ZonedDateTime and .NET CLR types such as DateTimeOffset.
- Neo4jParameters wrapper and Dictionary extension methods to assist in creating parameter maps when performing cypher updates.
- Superior performance due to the use of best-in-class mapper ServiceStack.Text.
- Targets .NET6.0.
- Examples.
The easiest way to add Neo4j.Mapper to your .NET project is to use the NuGet Package Manager.
From Visual Studio use the Nuget Package Manager to browse to the Neo4j.Mapper package and install it to your project. Alternatively, you can use the Package Manager Console:
Install-Package Neo4j.Mapper
If you are developing .NET Core projects and you are using the command line tools, then you can run the following command from within your project directory:
dotnet add package Neo4j.Mapper
Use Neo4j Docker image for testing
docker run -p7474:7474 -p7687:7687 -e NEO4J_AUTH=neo4j/s3cr3t neo4j
For general usage help please ask a question on StackOverflow. To report a bug, please raise an issue. To help make this software even better, please fork the repository, add your changes and raise a pull request.