Reputation: 26091
I'm trying to create a query the finds records who id is in a list, so I don't have query the database multiple times. My query however is throwing an error. How can I fix this?
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 ^
Upvotes: 1
Views: 822
Reputation: 16365
Try it (Using IN instead of 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();
}
Upvotes: 3