我是SQLite的新手,我正在尝试从SQLite数据库中获取字符串。但我无法返回people.Name,因为人们是AsyncTableQuery。有什么想法吗?
这是代码:
readonly SQLiteAsyncConnection _database;
public string GetNameByID(int id)
{
var people = from t in _database.Table<Model>() where t.ID == id select t;
return people.Name;
}
答案 0 :(得分:1)
定义AsyncTableQuery
后,您可以通过List
ToListAsync
示例:
var people = from t in _database.Table<Model>() where t.ID == id select t;
await people.ToListAsync();
foreach (var person in people)
{
Debug.WriteLine(person.Name);
}