Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.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中序列化/反序列化Json日期时间_C#_.net_Json_Serialization_Neo4jclient - Fatal编程技术网

C# 在Neo4jClient中序列化/反序列化Json日期时间

C# 在Neo4jClient中序列化/反序列化Json日期时间,c#,.net,json,serialization,neo4jclient,C#,.net,Json,Serialization,Neo4jclient,我使用Neo4jClient来使用Neo4j,我对CRUD实体使用cypher代码,遵循代码: _graphClient.Cypher.Merge("(n:Movie { Id:101 })") .Set("n.Key = 55,n.DateTime='" +DateTime.UtcNow.ToString()+"'").ExecuteWithoutResults(); _graphClient.Cypher .Match("(n:Movie)-

我使用Neo4jClient来使用Neo4j,我对CRUD实体使用cypher代码,遵循代码:

_graphClient.Cypher.Merge("(n:Movie { Id:101 })")
            .Set("n.Key = 55,n.DateTime='" +DateTime.UtcNow.ToString()+"'").ExecuteWithoutResults();

_graphClient.Cypher
            .Match("(n:Movie)-[r:RelName]-(m:Movie)")
            .Where((EntityNode n) => n.Id == 20)
            .Return.......

public class EntityNode
{
    public int Id { get; set; }
    public string Key { get; set; }
    public DateTime DateTime { get; set; }
}
错误:Neo4j返回了有效响应,但是Neo4jClient无法反序列化到您提供的对象结构中。无法反序列化DateTime

另一方面,我以不同的方式使用jsonconvertor,例如:

   _graphClient.Cypher.Merge("(n:Movie { Id:101 })")
                .Set("n.Key = 55,n.DateTime=" +JsonConvert.SerializeObject(DateTime.UtcNow)).ExecuteWithoutResults();

我仍然有错误

将其作为正确的参数传递:

graphClient.Cypher
    .Merge("(n:Movie { Id:101 })")
    .Set("n.Key = {key}, n.DateTime = {time}")
    .WithParams(new {
        key = 55,
        time = DateTimeOffset.UtcNow
    })
    .ExecuteWithoutResults();
这样,Neo4jClient将为您完成序列化,并且不会带来很多安全和性能问题


这在这里的文档中:

我最近遇到了同样的问题,因为它的日期时间值来自近地天体

我在neo中将日期时间存储为大纪元时间,但在检索时,我在课堂上使用了很长时间。正因为如此,它给了我上述的错误

尝试将字符串用于上述日期时间


希望这对您有所帮助。

如果我使用字符串而不是日期时间!工作但无法序列化datetime的类!我有错误