I'm having difficulties using Odata in combination with PageResult. I get the correct result, 5 items if I set [Queryable(PageSize=5)]
but no nextlink, which I expect, so I can get the next results of page 2 for example.
Composite C1 uses it's own XML datastore, and I think that's the core of the problem.
All of the examples I found for OData V3 (the version which is installed if you use http://www.composite.net/Products/Add-ons/All/Composite.AspNet.WebAPI) Tell me to just use [Queryable(PageSize=5)] and it should work out of the box. But they all use entity framework, which I don't and I think that's where it breaks.
this is my result, without the nextlink:
<Data>
<ImageItem>
<Id>1eeb46e3-1446-45e8-bab2-03ccb637b2ab</Id>
<Title/>
<SubTitle/>
</ImageItem>
<ImageItem>
<Id>1eeb46e3-1446-45e8-bab2-03ccb637b2ab</Id>
<Title/>
<SubTitle/>
</ImageItem>
<ImageItem>
<Id>1eeb46e3-1446-45e8-bab2-03ccb637b2ab</Id>
<Title/>
<SubTitle/>
</ImageItem>
<ImageItem>
<Id>1eeb46e3-1446-45e8-bab2-03ccb637b2ab</Id>
<Title/>
<SubTitle/>
</ImageItem>
<ImageItem>
<Id>1eeb46e3-1446-45e8-bab2-03ccb637b2ab</Id>
<Title/>
<SubTitle/>
</ImageItem>
</Data>
Code:
public class ImagesController : ApiController
{
public PageResult Get(ODataQueryOptions options)
{
using (var c = new DataConnection())
{
var querySettings = new ODataQuerySettings() { PageSize = 20 };
var filtered = options.ApplyTo(c.Get(), querySettings).Cast().ToList().AsQueryable();
return new PageResult(filtered, Request.GetNextPageLink(), 20);
}
}
}
Request.GetNextPageLink() returns http://xx.local/api/images?$skip=5
variable filtered has a list of 19 imageitems. and filtered.Count() returns 19 as well.
Does someone have a suggestion or even a solution? The composite C1 installation is a bare bones one, with no extra handlers. Composite C1 4.2 Update 1, Build no. 4.2.5287.17495