I can't succeed to find the right way to do this:
public Task<List<HWElDocument>> GetHWElDocumentsAsync(int? ProjectID = null)
{
// Get all Items
if (ProjectID == null)
return database.Table<HWElDocument>().ToListAsync();
// Or all items meeting a condition
else
{
// This line has to be awaited, I think ?!?
List<HWDocuProj> projList = await database.Table<HWDocuProj>().Where( item => item.ProjID == ProjectID).ToListAsync();
// So that I can use the result here:
return database.Table<HWElDocument>().Where(item => projList.Exists(p => p.ProjID == item.ID)).ToListAsync();
}
}
Because of the await keyword, the compiler ask to transform the function in an async function. But I do so, therefore it refuses that the result is a Task<T'> ... If I change the return type to async List<HWElDocument'>, then this line throws an error:
return database.Table<HWElDocument>().ToListAsync();
What is the correct way to achieve this then?