I an working on c# and use neo4jclient. I know neo4jclient can create a node if I pass a class object to it (I have tried it) Now in my class I want to add a dictionary property, this doesn't work. My code:
GraphClient client = getConnection();
client.Cypher
.Merge("(user:User { uniqueIdInItsApp: {id} , appId: {appId} })")
.OnCreate()
.Set("user = {newUser}")
.WithParams(new
{
id = user.uniqueIdInItsApp,
appId = user.appId,
newUser = user
})
.ExecuteWithoutResults();
The User
contains a property that is a Dictionary
in C#.
When executing the cypher it shows the error
MatchError: Map() (of class scala.collection.convert.Wrappers$JMapWrapper)
Can anyone help me?
By default Neo4j doesn't deal with Dictionaries (Maps in Java) so your only real solution here is to use a custom serializer and serialize the dictionary as a string property...
The code below only works for the type given, and you'll want to do something similar so you can use the default handling where possible, and only use this converter for your type:
Then to use in Neo4jClient:
It'll then use that converter when it can.