Issue
I am using SQLite.NET. I am trying to pass an integer array to a search query. I would like to return a list of records where the IDs (table attributes) match the integers in an array. The array is of size 10.
In 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);
In SQLiteDatabase.cs:
public List<Rooms> SearchList(int[] ID)
{
return database.Query<Rooms>("SELECT * FROM Rooms WHERE ID = ?;", ID);
}
This results in the following error when the query is executed:
System.NotSupportedException: Timeout exceeded getting exception details
How can I return a list of records where the IDs match? Thank you.
Solution
use the IN
keyword
WHERE ID IN (1, 2, 3, 4, 5)
Answered By - Jason
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.