static void Main(string[] args) { var client = new GraphClient(new Uri("http://localhost:7474/db/data")); client.Connect(); #region Simple get. var personNode = client.Get <Person>((NodeReference)903); //H.Write("Person-node", personNode); //H.Write("Person-id:", personNode.Reference.Id); //H.Write("Person:", personNode.Data); #endregion // Simple get. #region Cypher. var query = client .Cypher .Start(new { me = personNode }) .Match("me-[:FRIEND]->(other)") .Return <Node <Person> >("other"); var result = query.Results; H.Write("Friends of Ola", result.Select(n => n)); #endregion // Cypher. Console.WriteLine(); Console.Write("Press any key..."); Console.ReadKey(); }
private Node <Actor> EnsureActorIsInDb(GraphClient db) { if (!db.CheckIndexExists("Actors", IndexFor.Node)) { db.CreateIndex("Actors", new IndexConfiguration { Provider = IndexProvider.lucene, Type = IndexType.exact }, IndexFor.Node); } var actor = db.RootNode .Out <Actor>(ObjectBelongsTo.TypeKey, i => i.ActorName == this.ActorName) .FirstOrDefault(); if (actor == null) { var actorRef = db.Create <Actor>(this, new ObjectBelongsTo(db.RootNode)); actor = db.Get <Actor>(actorRef); } return(actor); }
private Tuple <Node <string>, NodeModel> GetNode(long id) { var node = _graphClient.Get <string>((NodeReference)id); dynamic data = JObject.Parse(node.Data); if (id == 0) { return(new Tuple <Node <string>, NodeModel>(node, new NodeModel { Id = 0, FriendlyId = "Root", Name = "Root", Type = "Root" })); } return(new Tuple <Node <string>, NodeModel>(node, new NodeModel { Id = node.Reference.Id, FriendlyId = data.Id, Name = data.Name, Type = data.Type })); }
public void ShouldThrowInvalidOperationExceptionIfNotConnected() { var client = new GraphClient(new Uri("http://foo")); client.Get<object>((NodeReference)123); }
public void ShouldThrowInvalidOperationExceptionIfNotConnected() { var client = new GraphClient(new Uri("http://foo")); Assert.Throws <InvalidOperationException>(() => client.Get <object>((NodeReference)123)); }