2017-04-12 181 views
0

我很新的SQLite,我試圖從SQLite數據庫中獲取一個字符串。但是我無法返回people.Name,因爲人是AsyncTableQuery。有任何想法嗎?SQLite數據庫訪問Xamarin.form

這是代碼:

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; 
} 

回答

1

一旦所述AsyncTableQuery定義,則可以把它帶到ListToListAsync經由

實施例:

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); 
}