1
votes

I am new to Neo4j and I develop the project using c#(Neo4jClient).

In my project i want to create approximately 3000 nodes at a time. Now I create single node by node because to avoid duplication's(i.e i check each time nodes exists or not. if only not exists then i create nodes.). now in neo4j have 1,60,000 nodes. so it will take 2 hours to complete 3000 nodes. I would like to use Batch Insertion. Please share me code to use batch insertion at this same to check duplication node. Thanks in advance.

1

1 Answers

1
votes

Example

public class Neo4jDataProvider<T>
    {
        IGraphClient _client = null;

        public Neo4jDataProvider(IGraphClient client)
        {
            _client = client;
        }

    public void CreateAll(IEnumerable<T> records)
    {
        if (_client != null)
        {
            var propKey = string.Format("{0}s", typeof (T).Name.ToLower());
            var query = _client.Cypher;
            var createString = string.Format("({0}:{1} {{{2}}})", "record", typeof(T).Name, propKey);
            query = query.Create(createString);
            query = query.WithParam(propKey, records.ToList());
            query.ExecuteWithoutResults();
        }
    }
}