Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在neo4jclient中使用unwind更新数据?_C#_Neo4j_Neo4jclient - Fatal编程技术网

C# 如何在neo4jclient中使用unwind更新数据?

C# 如何在neo4jclient中使用unwind更新数据?,c#,neo4j,neo4jclient,C#,Neo4j,Neo4jclient,我想更新neo4j数据库中的一些记录。为了在C#中的Neo4jClient中编写此查询: 其中,技能是技能对象的简单列表: public class Skill { public string Name { get; set; } public string Phrase { get; set; } } 但当我调用它时,这段代码抛出异常。其翻译的密码查询是: UNWIND [{

我想更新neo4j数据库中的一些记录。为了在C#中的Neo4jClient中编写此查询:

其中,技能是技能对象的简单列表:

    public class Skill
        {
            public string Name { get; set; }
            public string Phrase { get; set; }          
        }
但当我调用它时,这段代码抛出异常。其翻译的密码查询是:

UNWIND [{
    "Name": "name1",
    "Phrase": "phrase1",
},{
    "Name": "name2",
    "Phrase": "phrase2",
}] AS updatedSkill
MATCH (s : Skill {Name: updatedSkill.Name}
SET s = updatedSkill
例外情况如下:

     Invalid input '"': expected whitespace, comment, an identifier,
 UnsignedDecimalInteger, a property key name or '}' (line 3, column 5 (offset: 17))
    "    "Name": "name1","
         ^
删除属性名称和短语的双引号后,查询将正确运行。但是我可以这样做,因为查询是由Neo4jClient自动生成的


有什么想法吗?

您的
匹配语句中有一个输入错误。它缺少结束符
。如果您纠正了这一点,您的查询将按预期工作。另外,在
SET
语句的末尾还有一个分号,我已经删除了它

_client.Cypher
        .Unwind(skills, "updatedSkill")
        .Match("(s:Skill {Name: updatedSkill.Name})")
        .Set("s = updatedSkill")
        .ExecuteWithoutResults();
另外,这是一个示例,您正在查看的查询并不真正代表发送到Neo4j REST API的参数化查询。我假设您是通过查看
\u cypher.Query.DebugQueryText
获得它的?对于大多数情况,这很好,但在传递JSON对象时,由于它处理参数对象的字符串表示形式的方式,可能会导致错误的查询。如果查看Neo4jClient引发的实际异常,它应该会通知您问题的真正原因。在这种情况下

SyntaxException:无效输入“S”:应为空白、注释“)”或关系模式。。。 “设置s=updatedSkill”
^

这告诉您真正的问题是,在启动
SET
语句之前,您没有关闭
MATCH
语句

_client.Cypher
        .Unwind(skills, "updatedSkill")
        .Match("(s:Skill {Name: updatedSkill.Name})")
        .Set("s = updatedSkill")
        .ExecuteWithoutResults();