c# - Cypher 查询比较两个日期

标签 c# neo4j cypher

我有一个密码查询来比较两个日期。但是它出错了。这个查询有什么问题?有人可以帮忙吗?

GraphClient client= new GraphClient(new Uri("http://localhost:7474/"));
                              client.Connect();  
                              var date=client.Cypher
                              .Match("(e2:Event)")
                              .Where((Event e2) => Convert.ToDateTime(e2.notificationTime).CompareTo(DateTime.Now) < 0 )
                                .return(e=>e.As<Event>()).Results;

错误:

SyntaxException: Invalid input '{': expected an identifier character, whitespace, '?', '!', '.', node labels, '[', "=~", IN, IS, '*', '/', '%', '^', '+', '-', '<', '>', "<=", ">=", '=', "<>", "!=", AND, XOR, OR or ')' (line 25, column 25)"AND (e2.notificationTime{p7} < {p8})

最佳答案

首先,将“AndWhere”部分更改为“Where”,因为您不需要在该代码中链接“where”子句。可能是不能翻译成cypher的原因。

如果它仍然不起作用,那么我会说这个问题在你的“Where”子句中。 Convert.ToDateTime().CompareTo 可能无法转换为密码。那么你应该尝试简化你的代码。这取决于您的 e2.notificationTime 是什么类型。 例如,如果它是 Unix 格式:

var currentDate = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
GraphClient client= new GraphClient(new Uri("http://localhost:7474/"));
client.Connect();  
var date=client.Cypher
               .Match("(e2:Event)")
               .Where((Event e2) => e2.notificationTime < currentDate)
               .Return(e=>e.As<Event>()).Results;

你必须摆脱“where”子句中的任何复杂表达式,因为它正在翻译成密码

关于c# - Cypher 查询比较两个日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25196499/

相关文章:

c# - 无论如何将命令绑定(bind)到 XAML/WPF/MVVM 中的用户控件中的按钮的所有实例

c# - Xamarin Forms 从 PCL 请求互联网许可 Android 6

python - py2neo Graph.find_one() 弃用警告?

neo4j - Neo4j Cypher 查询传递闭包的性能不佳

Neo4j 在创建节点时向节点添加属性或特性

c# - SSRS 检查用户是否在使用自定义程序集的组中

c# - 参数验证失败。不可能为所有参数提供有效值。 (rsParameterError) sql 报告 2008

Neo4j TestGraphDatabase : Caused by: java. lang.IllegalStateException:文件仍在映射时无法关闭 PageCache:

performance - Neo4j 查询需要很长时间

database - 简化有条件地创建新关系的 Neo4j 查询