0

I am using HTTP POST for getting the data from the ODataController. But I m not able to query my service

[HttpPost]
[EnableQuery]
public IQueryable<MyDataObject> FetchCCMNewIssueLogViewGridData()
{
     var result = CCMModelDataContext.MyDataObject.AsQueryable();
     return result ;
}

How I can send request from the client side to accept as ODataQueryOptions object?

[HttpPost]        
public IQueryable<MyDataObject> FetchGridData(ODataQueryOptions<MyDataObject> options)
{
    var result = options.ApplyTo(CCMModelDataContext.MyDataObject.AsQueryable(), new ODataQuerySettings());
    return result as IQueryable<MyDataObject>;
}

But here in ODataQueryOptions object, I m getting 'Filter' and 'OrderBy' in the ODataQueryOptions object as null.

Here is my kendo parameter map method for creating the request

parameterMap: function (data, type) {
    var newData = customFilterOptions.grdParameterMap(data, type);    
    return JSON.stringify(newData );
},

How I can achieve this?

No need to modify query options in the API Controller. In which format I can send data to API for accepting it as ODataQueryOPtions object. As of now my 'Request payload' is

{$top: 20, $orderby: "field1 desc", $filter: "(field1 eq 2 and field2 eq 385)", $count: true, $skip : 20}

How I can do this? will this EnableQuery work with 'HTTP POST'? Thanks in advance

  • Do I need to apply FilterQueryOption, OrderByQueryOption, TopQueryOption and SkipQueryOption separately to my IQueryable in my API? – Ajay Unnikrishnan Oct 29 '17 at 14:48
  • What are you specifying in your request for the filter or order by? Does your request look similar to http://localhost:12345/Endpoint?$filter=id+eq+100 – mumfy Oct 30 '17 at 19:35
  • Nop. I am sending an HTTP POST. The query string part is inside the body. – Ajay Unnikrishnan Oct 31 '17 at 03:54
  • Oh, apparently I wasn't looking very closely. Have you seen this yet? https://stackoverflow.com/questions/24168213/possible-to-post-odataqueryoptions-from-the-http-request-body – mumfy Oct 31 '17 at 14:01
  • @mumfy : in that one, they are just passing the filter and using FilterQueryOption. I dont want to apply one by one. I m checking is there any do all the queries like filter , orderby, skip and sort in one shot. – Ajay Unnikrishnan Nov 03 '17 at 06:24
  • I m checking is there any way do all the queries like filter , orderby, skip and sort in one shot(using ODataQueryOptions). – Ajay Unnikrishnan Nov 03 '17 at 06:32
  • @Ajay: did you solve this yet? – Kien Chu Jan 29 '19 at 05:36

0 Answers0