Database Reference
In-Depth Information
Listing 7-6. Deleting a Relationship
var _graphClient = new GraphClient(new Uri("http://localhost:7474/db/data"));
// removing a relationship using a WHERE clause
_graphClient.Cypher
.Match("(user1:User)-[f:FOLLOWS]-(user2:User)")
.Where<User>(user1 => user1.userId == "10")
.AndWhere(user2 => user2.userId == "1")
.Delete("f")
.ExecuteWithoutResults();
// removing a relationship using a MATCH clause
_graphClient.Cypher
.Match(" (u1:User {username:{u1}} )-[f:FOLLOWS]->(u2:User {username:{u2}} ) ")
.WithParams( new {u1 = "user1", u2 = "user2"} )
.Delete("f")
.ExecuteWithoutResults();
Using Labels
Labels function as specific meta-descriptions that can be applied to nodes. Labels were introduced in Neo4j 2.0 to
help in querying, but they can also function as a way to quickly create a subgraph.
Adding a Label to Nodes
In Neo4jClient, you can add one more labels to a node. As Listing 7-7 shows, the SET is used to add a label to an
existing node.
Caution
a label will not exist on the database server until it has been added to at least one node.
Listing 7-7. Adding a Label to a Node
var _graphClient = new GraphClient(new Uri("http://localhost:7474/db/data"));
_graphClient.Cypher
.Match("(user:User)")
.Where<User>(user => user.userId == "10")
.Set(" user :Developer")
.ExecuteWithoutResults();
Removing a Label
Removing a label uses similar syntax as adding a label to a node. After the given label has been removed from the
node (Listing 7-8), the return value is a list of labels still on the node.
 
 
Search WWH ::




Custom Search