I want to send request like this:
/odata.svc/Pages(ItemId=27,PublicationId=1)
Here's the code I'm using:
CdService.ContentDeliveryService cdService = new ContentDeliveryService(new Uri("http://xxx.xx:81/odata.svc"));
var pages = cdService.Pages;
pages = pages.AddQueryOption("ItemId", "270");
pages = pages.AddQueryOption("PublicationId", "2");
var result = pages.Execute();
My problem is that this code is sending request like this:
/odata.svc/Pages()?ItemId=270&PublicationId=2
The problem with this request is that it returns me all the pages there are and not just the one I need.
I could use LINQ:
result.Single(page => page.ItemId == 27 && page.PublicationId == 1);
But the problem is that all the pages will still be sent over the wire
I've done a quick test with LINQ and it seems to be doing the correct query:
ContentDeliveryService.ContentDeliveryService service =
new ContentDeliveryService.ContentDeliveryService(new Uri("http://localhost:99/odata.svc"));
var page = from x in service.Pages
where x.ItemId == 2122
&& x.PublicationId == 16
select x;
foreach (var page1 in page)
{
Console.WriteLine(page1.Title);
}
Console.Read();