Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-17-2021 05:59 AM
BoltGraphClient _graphClient;
_graphClient = new BoltGraphClient(Uri, username, pass)
await _graphClient.ConnectAsync();
await _graphClient.Cypher
.Merge("(User:User { Id: ?id })")
.OnCreate()
.Set("User = ?objuser")
.WithParams(new
{
id = objuser.Id,
objuser
})
.ExecuteWithoutResultsAsync();
For above I am getting error
Neo4j.Driver.ClientException: 'Invalid input '?': expected whitespace, comment or an expression
"MERGE (CommunityUser:CommunityUser { Id: ?id })"
How to solve this?
Can anyone provide code reference for DotNet - Neo4jClient 4.1 ?
Solved! Go to Solution.
07-19-2021 03:07 AM
Hi,
What Dana suggested is NOT the same thing you tried.
The first error message:
'Invalid input '?': expected whitespace, comment or an expression (line 3, column 12 (offset: 62))
"SET user = ?objuser"
Is telling you the cypher is just invalid, and that it doesn't know how to interpret it
The second one:
The old parameter syntax {param} is no longer supported. Please use $param instead
Is telling you the syntax has changed, since 3.5 (IIRC) you now use $
instead.
All the best
Charlotte
07-17-2021 06:21 PM
@abhishinde01 I suspect its tripping as a result of
.Merge("(User:User { Id: ?id })")
and
.Set("User = ?objuser")
and the usage of ?
Per cypher examples · DotNet4Neo4j/Neo4jClient Wiki · GitHub the example provided and when passing parameters is
var newUser = new User { Id = 456, Name = "Jim" };
graphClient.Cypher
.Merge("(user:User { Id: {id} })")
.OnCreate()
.Set("user = {newUser}")
.WithParams(new {
id = newUser.Id,
newUser
})
.ExecuteWithoutResults();
so if you change
.Merge("(User:User { Id: ?id })")
to
.Merge("(User:User { Id: {id} })")
and
.Set("User = ?objuser")
to
.Set("User = {objuser}")
does this address your issue
07-18-2021 08:31 AM
I am using Neo4jClient 4.1.14.0 and Neo4j.Driver 4.3.67.1
I tried this at first time but it was giving following error -
Neo4j.Driver.ClientException: 'The old parameter syntax
{param}
is no longer supported. Please use$param
instead (line 1, column 42 (offset: 41))
"MERGE (User:User { Id: {id} })"
07-18-2021 11:11 AM
@abhishinde01 and given the error message which indicates 'The old parameter syntax {param} is no longer supported. Please use $param instead (line 1, column 42 (offset: 41))
if you change
MERGE (User:User { Id: {id} })"
to
MERGE (User:User { Id: $id })"
what is the outcome?
07-18-2021 11:11 PM
Thats the same issue i posted -
await _graphClient.ConnectAsync();
await _graphClient.Cypher
.Merge("(User:User { Id: ?id })")
.OnCreate()
.Set("User = ?objuser")
.WithParams(new
{
id = objuser.Id,
objuser
})
.ExecuteWithoutResultsAsync();
Neo4j.Driver.ClientException: 'Invalid input '?': expected whitespace, comment or an expression (line 1, column 42 (offset: 41))
"MERGE (CommunityUser:CommunityUser { Id: ?id })"
How to resolve this error?
I tried this as well -
await _graphClient.Cypher
.Match("(user:CommunityUser)")
.Where((CommunityUser user) => user.Id == objuser.Id)
.Set("user = ?objuser")
.WithParam("objuser", new CommunityUser { Id = objuser.Id, FirstName = objuser.FirstName, LastName = objuser.LastName})
.ExecuteWithoutResultsAsync();
This code giving me error -
Neo4j.Driver.ClientException: 'Invalid input '?': expected whitespace, comment or an expression (line 3, column 12 (offset: 62))
"SET user = ?objuser"
07-19-2021 03:07 AM
@abhishinde01
your original includes parameters referenced by / prefaced by a ?
, for example
.Merge("(User:User { Id: ?id })")
I am suggesting you change this to parameters referenced by/prefaced by a $
and thus
.Merge("(User:User { Id: $id })")
07-19-2021 03:07 AM
Hi,
What Dana suggested is NOT the same thing you tried.
The first error message:
'Invalid input '?': expected whitespace, comment or an expression (line 3, column 12 (offset: 62))
"SET user = ?objuser"
Is telling you the cypher is just invalid, and that it doesn't know how to interpret it
The second one:
The old parameter syntax {param} is no longer supported. Please use $param instead
Is telling you the syntax has changed, since 3.5 (IIRC) you now use $
instead.
All the best
Charlotte
07-19-2021 05:06 AM
Yes ... with $ its working absolutely fine
Thank you so much Guys
All the sessions of the conference are now available online