I created a Xamarin Forms app that used SQLite for the device database. I was able to make calls such as string name = GetItemByID(1).Result.item_name. This worked wonderfully, good performance and returned my data.
I have since converted my project to using Azure Mobile Apps with a node.js backend and WindowsAzure.MobileServices / MobileServices.SQLiteStore. Now, the exact same call in the exact same application never finishes. I have followed all of the Get Started tutorials for Azure Mobile Apps/App Services and the TodoAzure and other Todo tutorials.
On methods/objects where I don't need a specific row/column, I can retrieve data using the standard async Task await process. However, I have some settings that I need to pull from the database that require me to pull just a single row and a single column, synchronously. The app cannot proceed without this value so it must wait until this value is retrieved from the database. I can't seem to get this to work. It seems that the MobileServices requires all of the data retrieval to use async Tasks and everything I have tried has failed.
So what is the SQLite equivalent for the Task.Result.? Can I use SQLite alongside of (or instead of) MobileServices since SQLite just seems to work better? If so, any links or examples or tutorials would be very welcome.
SQLite call & method that works:
strAppID = GetApplicationInfoByName("App").Result.id;
public Task<ApplicationInfo> GetApplicationInfoByName(string name)
{
return sqlConn.Table<ApplicationInfo>().Where(t => t.name == name).FirstOrDefaultAsync();
}
MobileServices call & method that does not work. It simply hangs (I'm sure due to a blocking thread?)
strAppID = GetApplicationInfoByName("App").Result.id;
public async Task<ApplicationInfo> GetApplicationInfoByName(string name)
{
IEnumerable<ApplicationInfo> items = await appInfoTable
.Where(t => t.name == name)
.ToEnumerableAsync();
return items.FirstOrDefault();
}