private bool RelationshipExistsByQuery(RelationshipIndex index, Node startNode, Node endNode, bool specifyStartNode) { bool found = false; using (Transaction tx = Db.beginTx(), IndexHits <Relationship> query = index.Query("key", QueryContext.numericRange("key", 0, 3), specifyStartNode ? startNode : null, null)) { foreach (Relationship relationship in query) { if (relationship.StartNodeId == startNode.Id && relationship.EndNodeId == endNode.Id) { found = true; break; } } tx.Success(); } return(found); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void indexContentsShouldStillBeOrderedAfterRemovalOfKey() public virtual void IndexContentsShouldStillBeOrderedAfterRemovalOfKey() { string indexName = "index"; using (Transaction tx = Db.beginTx()) { Db.index().forNodes(indexName); tx.Success(); } long delete; long first; long second; long third; long fourth; using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); Node node = Db.createNode(); delete = node.Id; nodeIndex.Add(node, "keydelte", "delete"); node = Db.createNode(); second = node.Id; nodeIndex.Add(node, "key", ValueContext.numeric(2)); nodeIndex.Add(node, "keydelte", "delete"); node = Db.createNode(); fourth = node.Id; nodeIndex.Add(node, "key", ValueContext.numeric(4)); nodeIndex.Add(node, "keydelte", "delete"); node = Db.createNode(); first = node.Id; nodeIndex.Add(node, "key", ValueContext.numeric(1)); nodeIndex.Add(node, "keydelte", "delete"); node = Db.createNode(); third = node.Id; nodeIndex.Add(node, "key", ValueContext.numeric(3)); nodeIndex.Add(node, "keydelte", "delete"); tx.Success(); } using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); IndexHits <Node> query = nodeIndex.query("key", QueryContext.numericRange("key", 2, 3)); assertEquals(2, query.Size()); query.forEachRemaining(node => assertTrue(node.Id == second || node.Id == third)); } using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); nodeIndex.Remove(Db.getNodeById(delete), "keydelete"); nodeIndex.Remove(Db.getNodeById(first), "keydelete"); nodeIndex.Remove(Db.getNodeById(second), "keydelete"); nodeIndex.Remove(Db.getNodeById(third), "keydelete"); nodeIndex.Remove(Db.getNodeById(fourth), "keydelete"); tx.Success(); } using (Transaction tx = Db.beginTx()) { Index <Node> nodeIndex = Db.index().forNodes(indexName); IndexHits <Node> query = nodeIndex.query("key", QueryContext.numericRange("key", 2, 3)); assertEquals(2, query.Size()); query.forEachRemaining(node => assertTrue(node.Id == second || node.Id == third)); } }