c# - 如何在 Cypher Query 的 where IN 子句中使用 int[](使用 C#)
问题描述
我有这个密码查询
int[] pIds = new int[] {101, 012};
var query = _graphClient.Cypher.Read
.OptionalMatch($"(p: {Labels.PERSON})")
.Where($"p.Id IN [{pIds}]")
.Return<Person>(p);
在调试时它看起来像这样:
OPTIONAL MATCH (p: Person)
WHERE p.Id IN [System.Int32[]]
RETURN distinct p
我应该在这个 where 子句 [101, 012] 中传递的值,但不是。因为 pIds[0] = 101,pIds[1] = 012 - 并且它从未在密码查询中读取。
我在哪里出错并且未能传递价值观?我应该如何在 Where IN... 中传递 int[]
解决方案
最好的可能是使用参数:
int[] pIds = new int[] {101, 012};
var query = _graphClient.Cypher.Read
.OptionalMatch($"(p: {Labels.PERSON})")
.Where($"p.Id IN $pIds")
.Return<Person>(p)
.WithParam("pIds", pIds);
推荐阅读
- python - 模型输入:传递给模型的 Numpy 数组列表不是模型预期的大小。预计会看到 1 个数组,但得到了 142 个数组的列表
- python - 多个子进程如何在 python 中写入同一个共享内存数据帧?
- javascript - 如何在Vue中将重复的组件事件传递给父级
- javascript - 无法在函数中设置值
- excel - 查找重复项和重命名主/子
- javascript - 鼠标事件的问题
- mongodb - 无法启动 Mongo DB
- sql-server - 将字典值从 python 传递到 sql 存储过程
- reactjs - 功能性反应本机组件中的onPress不起作用
- jdbc - Neo4j:与 Power Bi 的连接