I'm creating a new Xamarin Forms application and I use a Azure Mobile App connected to a SQL Azure database.
Here is a code I wrote to query a table :
IEnumerable<Club> clubs = await (from club in ClubManager.DefaultManager.ClubTable.CreateQuery()
where club.Nom.Contains(TexteRecherche)
select club).ToEnumerableAsync();
I randomly get the following exception :
The exception
Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException occurred
HResult=0x80131509
Message=The request could not be completed. (Bad Request)
Source = <Unable to evaluate the source of the exception>
Procedural Call Tree:
à Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.<ThrowInvalidResponse>d__24.MoveNext()
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.<SendRequestAsync>d__26.MoveNext()
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.<RequestAsync>d__18.MoveNext()
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à Microsoft.WindowsAzure.MobileServices.MobileServiceTable.<ReadAsync>d__20.MoveNext()
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à Microsoft.WindowsAzure.MobileServices.MobileServiceTable.<ReadAsync>d__18.MoveNext()
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à Microsoft.WindowsAzure.MobileServices.Query.MobileServiceTableQueryProvider.<Execute>d__8`1.MoveNext()
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à Microsoft.WindowsAzure.MobileServices.Query.MobileServiceTableQueryProvider.<Execute>d__7`1.MoveNext()
à System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
à System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
à EagleGolf.CourseEditor.ViewModels.MainPageViewModel.<LitClubs>d__23.MoveNext() dans D:\Julien\MobileApps\EagleGolf.CourseEditor\EagleGolf.CourseEditor\EagleGolf.CourseEditor\ViewModels\MainPageViewModel.cs :ligne 107
build : `
It's very strange because I close and start again the application and it works again. It can work 2-3 times, then stop working, then work again.
My database contain only 1 table and this table contains only 2 records ...
IEnumerable<Club> clubs = await (from club in ClubManager.DefaultManager.ClubTable.CreateQuery()
where club.Nom.Contains(TexteRecherche)
select club).ToEnumerableAsync();
For IMobileServiceTable
table, the above query would send the following request against your mobile app backend:
Get https://{your-app-name}.azurewebsites.net/tables/{table-name}?$filter=substringof('{TexteRecherche}',Nom)
Message=The request could not be completed. (Bad Request)
I assumed that you could leverage Fiddler and check with your code when invoking the related queries as follows:
User contributions licensed under CC BY-SA 3.0