Database Reference
In-Depth Information
Neo4jClient is maintained by the super-awesome tatham oddie and supported by a number of great .Net
Neo4j developers. If you would like to get involved with Neo4jClient, go to https://github.com/Readify/Neo4jClient .
Note
Each of the following brief sections covers concepts that tie either directly or indirectly to features of Neo4jClient.
If you choose to go through each language chapter, you should notice how each library covers those features and
functionality in similar ways but takes advantage of the language-specific capabilities to ensure the language-specific
API is flexible and performant.
Managing Nodes and Relationships
Chapters 1 and 2 covered the elements of a graph database, including the most basic of graph concepts, the node.
Managing nodes and their properties will probably account for the bulk of your application's graph-related code.
Creating a Node
The maintenance of nodes is set in motion with the creation process, as shown in Listing 7-1. Creating a node begins
with setting up a connection to the database and making the node instance. Next, the node properties are set, and
then the node can be saved to the database.
Listing 7-1. Creating a Node
var _graphClient = new GraphClient(new Uri("http://localhost:7474/db/data"));
User user = new User { username = "Greg"};
// use ExecuteWithoutResults if you do not need to return a result node.
_graphClient.Cypher
.Create(" (user:User {user}) ")
.WithParam("user",user)
.ExecuteWithoutResults();
// or use results with single to return the first node returned in the collection.
User resultUser = _graphClient.Cypher
.Create(" (user:User {user}) ")
.WithParam("user",user)
.Return(u => u.As<User>())
.Results.Single();
although it is possible to manually construct and execute Cypher queries with the Neo4jClient, it is highly
discouraged because it could introduce security issues through Cypher injections.
Warning
 
 
Search WWH ::




Custom Search