private static Node<PO.Workers> AddWorkersRootNode(GraphClient client, Node<PO.Root> rootNode)
        {
            var nodeRef = client.Create(PO.Workers.Create("Workers"), null,
                new[]{
                    new IndexEntry{
                        Name=NameIndexName,
                        KeyValues=new[]{
                            new KeyValuePair<string,object>("Name", "Workers")
                        }
                    }
                });

            client.CreateRelationship<PO.Root, Relationships.RelatedToRelationship>(rootNode.Reference, new Relationships.RelatedToRelationship(nodeRef));

            var ret = client.Get<PO.Workers>(nodeRef.Id);

            client.Update<PO.Workers>(ret.Reference, node => { node.SetID(ret.Reference.Id); });

            ret = client.Get<PO.Workers>(nodeRef.Id);

            Debug.Assert(ret.Reference.Id == ret.Data.ID);
            Debug.Assert(ret.Reference.Id == nodeRef.Id);
            Debug.Assert(ret.Reference.Id == GetWorkersRootNode(client, rootNode).Reference.Id);

            return ret;
        }
        private static Node<PO.Worker> AddWorker(string name, GraphClient Client, Node<PO.Workers>WorkersRootNode)
        {
            var workerNodeRef = Client.Create(
                PO.Worker.Create(name),
                null,
                new[]
                {
                    new IndexEntry
                    {
                        Name = "my_index",
                        KeyValues = new[]
                        {
                            /* new KeyValuePair<string, object>("key", "value"), new KeyValuePair<string, object>("key2", ""), */ new KeyValuePair<string, object>("key3", "value3")
                        }
                    }
                }
            );

            Client.Update<PO.Worker>(workerNodeRef, node => { node.SetID(workerNodeRef.Id); });

            var workersRootNode = WorkersRootNode;

            var rel = Client.CreateRelationship<PO.Workers, Relationships.HasItemRelationship>(
                workersRootNode.Reference,
                new Relationships.HasItemRelationship(workerNodeRef)
                );

            var workerNode = Get(workerNodeRef.Id, Client);

            return workerNode;
        }
        protected static Node<PO.Workers> GetWorkersRootNode(GraphClient client, Node<PO.Root> rootNode)
        {
            //var rootNode = GetRootNode(client);
            //var query = new CypherQuery("start R=node({p0}) match R-[:RELATED_TO]->N where N.__Type=\"Workers\" return N;", new Dictionary<string, object>() { { "p0", rootNode.Reference.Id } }, CypherResultMode.Set);

            var query = new CypherQuery("start R=node({p0}) match R-[:RELATED_TO]->WR where WR.Name='Workers' return WR;", new Dictionary<string, object>() { { "p0", rootNode.Reference.Id } }, CypherResultMode.Set);
            var node = client.ExecuteGetCypherResults<Node<PO.Workers>>(
                query
                );
            return node.SingleOrDefault();
        }
        internal IList<PO.Chunk> GetByWorker(Node<PO.Worker> worker, GraphClient client)
        {
            //  start n=node(61) match n-[:HAS_WORKED]->b return b;

            var query = new CypherQuery("start n=node({workerNodeID}) match n-[:HAS_WORKED]->b return b;", new Dictionary<string, object>() { { "workerNodeID", worker.Reference.Id } }, CypherResultMode.Set);

            var chunks = Client.ExecuteGetCypherResults<Node<PO.Chunk>>(query);

            return chunks.Select(n => n.Data).ToList();
        }
        internal Node<PO.Chunk> Add(DateTimeOffset start, DateTimeOffset stop, TimeSpan duration, Node<PO.Worker> owningWorkerNode, Neo4jClient.GraphClient Client, Neo4jClient.Node<PO.Root> RootNode)
        {
            var chunkNodeRef = Client.Create(
                PO.Chunk.Create(start, stop, duration),
                null,
                new[]
                {
                    new IndexEntry
                    {
                        Name = "NameIndex",
                        KeyValues = new[]
                        {
                            new KeyValuePair<string,object>("Name", "Chunk")
                        }
                    }
                }
            );

            //  I update all fields again because I have a problem with serialising/deserialising DateTimeOffset - I lose the fractions of a second.  Not that it matters in my project but rätt skall vara rätt.
            Client.Update<PO.Chunk>(chunkNodeRef, node => { node.Set(chunkNodeRef.Id, start, stop, duration); });

            var rel = Client.CreateRelationship<PO.Worker, Relationships.HasWorkedRelationship>(
                owningWorkerNode.Reference,
                new Relationships.HasWorkedRelationship( chunkNodeRef)
                );

            var ret = Get( chunkNodeRef.Id, Client );

            return ret;
        }