-
Notifications
You must be signed in to change notification settings - Fork 6
Home
sonyarouje edited this page Feb 6, 2012
·
12 revisions
Neo4jD is a light weight .NET client to access Neo4j graph database. The library is still under development.
Create a Node
Node sony=new Node
sony.AddProperty("FirstName", "Sony").SetProperty("LastName", "Arouje").Create();
Node viji= new Node();
viji.AddProperty("FirstName", "Viji").AddProperty("LastName", "P").Create();
Relationship relationship= sony.CreateRelationshipTo(viji, "wife");
Get a Node
Node sony=Node.Get(1);
Add a New property to an existing node
- The function AddProperty is used to set any property before saving and the properties will persist while Creating the entity.
- The function SetProperty is used to set any new property to a persisted entity as shown below.
Node sony=Node.Get(1); sony.SetProperty("Profession","Developer");
Out flowing Relationship
IList<Node> outNodes=sony.Out()
Graph Traversal using REST Api
Node node = Node.Get(19);
RestTraversal r = new RestTraversal();
r.Order(OrderType.breadth_first)
.Filter ( new PropertyFilter().SetPropertyName("FirstName").Contains("marry") )
.RelationShips(RelationshipDirection.out_direction, "wife")
.RelationShips(RelationshipDirection.all_direction, "loves")
.Uniqueness(UniquenessType.node_global)
.MaxDepth(2);
IList<Node> nodes = node.Filter(r);
//you can see the generated query by
r.ToString()
The Generated Json query will look some thing like below
{
"order": "breadth_first",
"return_filter": {
"body": "position.endNode().getProperty('FirstName').toLowerCase().contains('sony')",
"language": "javascript"
},
"relationships": [
{
"direction": "out",
"type": "wife"
},
{
"direction": "all",
"type": "loves"
}
],
"uniqueness": "node_global",
"max_depth": 2
}
Note
You will get more insight of the current functionality by going through the NUnit tests.