[Azure] Working with Boolean values in Windows Azure Mobile Services queriesJanuary 8th, 2013 | Posted by in .NET | Article | Mobile Services | Windows 8 | Windows Phone | Read: 2,080
During my last holidays, I’ve started to work on a new Windows 8 project (more details on that later) that use Windows Azure Mobile Services as a backend.
During the development, I’ve encountered the following issue which, I suppose, is a bug that will be fixed later.
On my application, I used the following code:
var allItems = await ServiceClient.GetTable<Items>().Where(i => i.IsPublished).ToListAsync(); return allItems;
Unfortunately, this code thrown, every time, the following error:
After taking a look in Fiddler, I found the problem:
As you may know, Mobile Services use REST to access data on the server and the following REST query does not seem to be valid because there is no query operator (like eq for equal, etc.) and no value. So, I’ve tried to modify my code like this:
var allItems = await ServiceClient.GetTable<Items>().Where(i => i.IsPublished == true).ToListAsync(); return allItems;
As you can see, I’ve just append “== true” to the Where clause and all seems to work like a charm. Indeed, no exception was rise and, looking at the REST query, we can see that all is OK: