I have created a Xamarin.Forms project and now I intend to consume some data from a WCF Data Service.
I create the query like this:
MyEntities entities = new MyEntities(new Uri("http://localhost/MyService.svc/"));
DataServiceQuery<MyServiceReference.Info> query = entities.CreateQuery<MyServiceReference.Info>("GetInfo");
query.AddQueryOption("infoTag", "abc");
query.BeginExecute((result) =>
{
try
{
var que = result.AsyncState as DataServiceQuery<MyServiceReference.Info>;
var res = que.EndExecute(result);
foreach (var item in res)
{
System.Diagnostics.Debug.WriteLine(item.Name);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}, query);
According to this tutorial, I should see the complete query along with the parameters.
When I check the query URI, it is this: http://localhost/MyService.svc/GetInfo
It seems that the parameters are missing.
How could I add them properly?
Well, I figured it out...
I like Fluent syntax very much but I forgot to check if CreateQuery
uses that.
So instead of
query.AddQueryOption("infoTag", "abc");
I have to use this:
query=query.AddQueryOption("infoTag", "abc");
or this:
DataServiceQuery<MyServiceReference.Info> query = entities.CreateQuery<MyServiceReference.Info>("GetInfo").AddQueryOption("infoTag", "abc");