Sqlite-net: 'AsyncTableQuery<obj>' does not contain a definition for 'GetAwaiter'

Created on 1 Oct 2017  路  2Comments  路  Source: praeclarum/sqlite-net

In Xamarin Shared VS2015 sqlite-net-pcl 1.4.118

I try this code
public async Task > GetAlComplete()
{
query = await _connection.Table().Where(v => v._naam.StartsWith("A"));
return await query.ToListAsync();
}
get this error
Severity Code Description Project File Line Suppression State Error CS1061 'AsyncTableQuery' 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?)

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

Most helpful comment

@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

All 2 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

plamen-i picture plamen-i  路  6Comments

ToddThomson picture ToddThomson  路  3Comments

UweKeim picture UweKeim  路  5Comments

rynjas picture rynjas  路  3Comments

kapsiR picture kapsiR  路  5Comments