我尝试创建查询,查找id在列表中的记录,因此我不会多次查询数据库。然而,我的查询是抛出错误。我该如何解决这个问题?
public static IEnumerable<Task> GetByIds(List<string> ids)
{
return DBUtils.DBService.Cypher
.Match("(node:Task)")
.Where((Task node) => ids.Contains(node.Id))
.Return(node => node.As<Task>())
.Results.ToList();
}
SyntaxException: Invalid input 'n': expected whitespace, '.', node labels, '[', \"=~\", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', \"<>\", \"!=\", '<', '>', \"<=\", \">=\", AND, XOR, OR, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, RETURN, UNION, ';' or end of input (line 2, column 11 (offset: 33))\n\"WHERE {p0}node.Id\r\"\n ^
答案 0 :(得分:3)
尝试一下(使用IN而不是CONTAINS):
public static IEnumerable<CareTask> GetByReferenceIds(List<string> ids)
{
return DBUtils.DBService.Cypher
.Match("(node:Task)")
.Where("node.Id IN {ids}")
.WithParam("ids", ids)
.Return(node => node.As<Task>())
.Results.ToList();
}