我最初在这里发布了http://hg.readify.net/neo4jclient/issue/122/createunique-withparam-object
我正在使用neo4jclient 1.0.0.590运行neo4j 1.9.1
继续这个问题 http://hg.readify.net/neo4jclient/issue/66/support-custom-parameters-in-cypher-fluent
我正在尝试重用该语法来创建一个关系和一个具有属性的节点
var docoType = new DocumentationType() {DocumentationTypeId = message.DocumentationTypeId, Description = message.DocumentationTypeDescription};
_connectedClient.Cypher
.Start(new {docType = docTypeCategory})
.CreateUnique("docType-[r:{ISDOCTYPERELAT]}->(newDocType {possiblyNewDocoType})")
.WithParam("ISDOCTYPERELAT", IsDocumentationType.TypeKey)
.WithParam("possiblyNewDocoType", docoType)
.Return<Node<DocumentationType>>("newDocType");
_log.Info(JsonConvert.SerializeObject(createDocType.Query));
当我要求结果时,这里有来自小提琴手的一些结果
POST
{
"query" : "START docType=node({p0})\r\nCREATE UNIQUE (docType) - [r:{ISDOCTYPERELAT}]-> (newDocType {possiblyNewDocoType})\r\nRETURN newDocType",
"params" : {
"p0" : 538,
"ISDOCTYPERELAT" : "DOCTYPES",
"possiblyNewDocoType" : {
"DocumentationTypeId" : "USERADMINISTRATION",
"Description" : "User Administration"
}
}
}
RESPONSE
{
"message" : "string matching regex ``(``|[^`])*`' expected but `{' found\n\nThink we should have better error message here? Help us by sending this query to cypher@neo4j.org.\n\nThank you, the Neo4j Team.\n\n\"CREATE UNIQUE (docType) - [r:{ISDOCTYPERELAT}]-> (newDocType {possiblyNewDocoType})\r\"\n ^",
"exception" : "SyntaxException",
"fullname" : "org.neo4j.cypher.SyntaxException",
"stacktrace" : ["org.neo4j.cypher.internal.parser.v1_9.CypherParserImpl.parse(CypherParserImpl.scala:47)", "org.neo4j.cypher.CypherParser.parse(CypherParser.scala:44)", "org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:80)", "org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:80)", "org.neo4j.cypher.internal.LRUCache$LazyValue.value$lzycompute(LRUCache.scala:27)", "org.neo4j.cypher.internal.LRUCache$LazyValue.value(LRUCache.scala:27)", "org.neo4j.cypher.internal.LRUCache.getOrElseUpdate(LRUCache.scala:39)", "org.neo4j.cypher.ExecutionEngine.prepare(ExecutionEngine.scala:80)", "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:72)", "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:76)", "org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:79)", "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:94)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)"]
}
我手动接受了querytext并删除了键引号并让它成功运行
//THIS WORKS
START docType=node(538)
CREATE UNIQUE docType-[r:DOCTYPES]->(newDocType {
DocumentationTypeId : "USERADMINISTRATION",
Description : "User Administration"
})
RETURN newDocType
我在这里做错了吗?
谢谢!
答案 0 :(得分:2)
解决了我的问题!
我正在对这种关系进行参数化,这可能是一个很大的禁忌。
这个c#查询工作
var createDocType = _connectedClient.Cypher
.Start(new {docType = docTypeCategory})
.CreateUnique("(docType) - [r:"+ IsDocumentationType.TypeKey+ "]-> (newDocType {possiblyNewDocoType})")
.WithParam("possiblyNewDocoType", docoType)
.Return<Node<DocumentationType>>("newDocType");
```