Search code examples
c#neo4jneo4jclient

How to get Neo4JClient to perform a bulk insert


When running the following code I receive an exception "CypherTypeException: Collections containing mixed types can not be stored in properties." - What am I doing wrong, and what needs to change to make it work?

        var wordObjs = new List<object>();
        foreach (string word in WordGroups.GetAllWords())
        {
            wordObjs.Add(new { Value = word});
        }
        GraphClient.Cypher
            .Create("(word:Word {words})")
            .WithParam("words", new { words = wordObjs})
            .ExecuteWithoutResults();

Solution

  • One solution would be use a concrete class

    private class Value { 
        public string Value {get;set;} 
    }
    

    and use new List<Value>() instead, I think the client is having trouble with the anonymous nature of your List.