Get ODataQueryOptions in HTTPPOST method

696 Views Asked by At

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

0

There are 0 best solutions below