The query.ToString()
will give you the string representation of the underlying mobile service class, something like Microsoft.WindowsAzure.MobileServices.MobileServiceTableQuery``1[System.String]
probably not what you want!
I'm assuming you wanted to return the actual mammalDeviceID? If so you need two adjustments,
- You can't assume there will only be one row returned, so will need to expect a
List<String>
not just aString
. If you want just one back, you can addTake(1)
to the query (but it's still a list). - You need to execute the query by materializing it on the client, in this case,
ToListAsync()
should work.
So something like:
public static async Task<List<string>> GetMammalDeviceID(string mammalID, string zoologistDeviceID)
{
IMobileServiceTable<DUCKBILLED_PLATYPI> table = App.MobileService.GetTable<DUCKBILLED_PLATYPI>();
MobileServiceTableQuery<String> query =
table.Where(i => i.mammalID == mammalID).
Where(j => j.zoologistDeviceID == zoologistDeviceID).
Select(k => k.mammalDeviceID);
return await query.ToListAsync()
}
As for the second part, there's not difference other than verbosity. I think the fluid nature of the first option is more readable.