C# neo4j - 不能在 MERGE 模式中使用参数映射(改用文字映射
C# neo4j - Parameter maps cannot be used in MERGE patterns (use a literal map instead
我想用参数作为对象创建节点之间的关系,如 -
await _graphClient.ConnectAsync();
await _graphClient.Cypher
.Match("(obj1:Client)")
.Where((Client obj1) => obj1.ClientId == UserId)
.Match("(obj2:Job)")
.Where((Job obj2) => obj2.Id == JobId)
.Merge("(obj1)-[r:JOB_POSTED $relationobj1]->(obj2)")
.WithParam("relationobj1", relationobj1)
.ExecuteWithoutResultsAsync();
以上代码给出错误 -
{"Parameter maps cannot be used in MERGE patterns (use a literal map instead, eg. "{id: {param}.id}") (line 5, column 29 (offset: 130))\n"MERGE (obj1)-[r:JOB_POSTED $relationobj1]->(obj2)"\n
如果我从关系参数中删除 $relationobj1,它会起作用。
对象关系obj1是这样生成的-
JOBS_POSTED relationobj1 = new JOBS_POSTED();
relationobj1.createddate = DateTime.UtcNow;
知道将参数作为对象传递的正确方法是什么吗?
提前致谢
请尝试使用 set
。性能方面 - 没有区别。
await _graphClient.ConnectAsync();
await _graphClient.Cypher
.Match("(obj1:Client)")
.Where((Client obj1) => obj1.ClientId == UserId)
.Match("(obj2:Job)")
.Where((Job obj2) => obj2.Id == JobId)
.Merge("(obj1)-[r:JOB_POSTED]->(obj2)")
.Set("r = $relationobj1") //HERE
.WithParam("relationobj1", relationobj1)
.ExecuteWithoutResultsAsync();
我想用参数作为对象创建节点之间的关系,如 -
await _graphClient.ConnectAsync();
await _graphClient.Cypher
.Match("(obj1:Client)")
.Where((Client obj1) => obj1.ClientId == UserId)
.Match("(obj2:Job)")
.Where((Job obj2) => obj2.Id == JobId)
.Merge("(obj1)-[r:JOB_POSTED $relationobj1]->(obj2)")
.WithParam("relationobj1", relationobj1)
.ExecuteWithoutResultsAsync();
以上代码给出错误 -
{"Parameter maps cannot be used in MERGE patterns (use a literal map instead, eg. "{id: {param}.id}") (line 5, column 29 (offset: 130))\n"MERGE (obj1)-[r:JOB_POSTED $relationobj1]->(obj2)"\n
如果我从关系参数中删除 $relationobj1,它会起作用。
对象关系obj1是这样生成的-
JOBS_POSTED relationobj1 = new JOBS_POSTED();
relationobj1.createddate = DateTime.UtcNow;
知道将参数作为对象传递的正确方法是什么吗?
提前致谢
请尝试使用 set
。性能方面 - 没有区别。
await _graphClient.ConnectAsync();
await _graphClient.Cypher
.Match("(obj1:Client)")
.Where((Client obj1) => obj1.ClientId == UserId)
.Match("(obj2:Job)")
.Where((Job obj2) => obj2.Id == JobId)
.Merge("(obj1)-[r:JOB_POSTED]->(obj2)")
.Set("r = $relationobj1") //HERE
.WithParam("relationobj1", relationobj1)
.ExecuteWithoutResultsAsync();