我有一个密码查询来比较两个日期。但是它出错了。这个查询有什么问题?有人可以帮忙吗?
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/