My app makes a simple call the an Azure Webservice database and I want to copy the returned rows into a new list.
private IMobileServiceTable<dbEntry> entryTable = App.MobileService.GetTable<dbEntry>();
private MobileServiceCollectionView<dbEntry> currentEntries;
currentEntries = (entryTable.Where(ev => ev.event_date.Month == dateToShow.Month)
.ToCollectionView());
foreach (dbEntry ev in currentEntries)
{
//insert ev into another List
}
The problem is that the “where” call to the DB is asynchronous, so by the time the loop is reached there are no elements in currentEntries yet.
How can I detect that the call has completed before executing the loop? Is there an event handler for this?
Thank you.
It sounds like you found this solution already but I’ll post it for anyone else that comes across this.
Unless you directly want to bind a UI element to the results of the operation, I suggest you do not use the ToCollectionView method. Instead, do the following: