c# - 选择 ID 匹配 int 数组的 SQLite.NET 记录
问题描述
我正在使用 SQLite.NET。我正在尝试将整数数组传递给搜索查询。我想返回 ID(表属性)与数组中的整数匹配的记录列表。数组大小为 10。
在 MainPage.cs 中:
int[] arr = new int[10];
// for testing purposes
for (int i = 0; i <= 9; i++{
arr[i] = i;
}
var selected = App.Database.SearchList(arr);
在 SQLiteDatabase.cs 中:
public List<Rooms> SearchList(int[] ID)
{
return database.Query<Rooms>("SELECT * FROM Rooms WHERE ID = ?;", ID);
}
这会在执行查询时导致以下错误:
System.NotSupportedException:超时获取异常详细信息
如何返回 ID 匹配的记录列表?谢谢你。
解决方案
使用IN
关键字
WHERE ID IN (1, 2, 3, 4, 5)
推荐阅读
- haskell - Haskell 没有得到我的功能依赖
- docker - 从局域网设备访问 docker 容器
- pyspark - 比较 2 个 pyspark 数据框列并根据它更改另一列的值
- java - 如何为 Java 应用程序正确安装 JRE/JDK 并进行验证
- javascript - 对象属性传播和 Object.assign
- java - 根据 String[] 索引更改字符串值
- javascript - 嵌套表的 2 窗格 crud 表视图(主表和详细表)
- python - 如何将 Python 输出从 for 循环写入文件?
- java - 在尝试连接后,我一直无法将 java.math.bigInteger 转换为 java.lang.Long
- makefile - 如何在使用并行执行时使用特定于目标的变量值并调用其他规则?