Open Whrothus opened 7 years ago
You need to remove the "await" from the first line in your method. There is no async operation in this line, so you cannot await it. The second line is Async (ToListAsync), so you need to await it. So, it's not a SQLite issue.
public async Task<List > GetAlComplete()
{
query = _connection.Table().Where(v => v._naam.StartsWith("A"));
return await query.ToListAsync();
}
@praeclarum I came across this issue today too because the sample code in the README indicates you need the await keyword. Can the README be updated to read correctly. cheers
In Xamarin Shared VS2015 sqlite-net-pcl 1.4.118
I try this code public async Task<List > GetAlComplete()
{
query = await _connection.Table().Where(v => v._naam.StartsWith("A"));' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'AsyncTableQuery' could be found (are you missing a using directive or an assembly reference?)
return await query.ToListAsync(); } get this error Severity Code Description Project File Line Suppression State Error CS1061 'AsyncTableQuery
I try this var query = await _connection.Table().ToListAsync();
return query;
No problem it runs normal (i get the full list)
Some background code private SQLiteAsyncConnection _connection; _connection = Xamarin.Forms.DependencyService.Get().GetConnection();
public interface ISQLiteDb
{
SQLiteAsyncConnection GetConnection();
}
[assembly: Dependency(typeof(SQLiteDb))]
namespace MyProject.Droid.DataBase
{
class SQLiteDb : ISQLiteDb
{
public SQLiteAsyncConnection GetConnection()
{
var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var path = Path.Combine(documentsPath, "MySQLite.db3");
return new SQLiteAsyncConnection(path);
}
}
}
class CheckList : IDataBaseObject
{
[Ignore]
static public MainBussines _mainBuss { get; set; }
[PrimaryKey , AutoIncrement]
public int ID { get; set; }
[MaxLength(255)]
public string _naam { get; set; }
}