0

I have the following method in controller.

public class CompaniesController : ApiController
{

    static IList<Models.ClientCompany> list = new List<Models.ClientCompany>();

    public object Get(int skip)
    {

        list.Clear();
        var queryString = HttpContext.Current.Request.QueryString;
        int skip = Convert.ToInt32(queryString["$skip"]);
        int take = Convert.ToInt32(queryString["$top"]);
        int countPages = 0;

        list.Add(new Models.ClientCompany(1, "Krzak"));
        list.Add(new Models.ClientCompany(2, "Agrawka"));
        list.Add(new Models.ClientCompany(3, "Filut"));
        list.Add(new Models.ClientCompany(4, "Beczka"));
        list.Add(new Models.ClientCompany(5, "Progress"));
        if (take == 0)
        {
            countPages = list.Count;
            take = list.Count;
        }

        if (queryString["$inlineCount"] != null)
        {
            string allPages = queryString["$inlineCount"].ToString();
            countPages = list.Count;
        }
        return new {
            Items = list.Skip(skip).Take(take),Count=countPages
        };
    }

}

I want use something instead of QueryString to identify parameter skip in headline method. Like this.

public object Get([some attribute]int skip)

Example of request.

api/cmp/?$inlinecount=allpages&$orderby=cmpn%20desc&params=[object%20Object]&$skip=4&$top=2
maciejka
  • 818
  • 2
  • 17
  • 42
  • You say `I have the following method.` but that method is simply not possible. You cannot declare `skip` multiple times in the same scope. Not really sure why you have a parameter `skip` that you assign immediately after the method is entered, its neither `ref` or `out`. – erikvimz Oct 26 '17 at 09:10
  • 1
    Looks like a dupe of https://stackoverflow.com/q/12298409/728795 – Andrei Oct 26 '17 at 09:12
  • Sorry @ErikKralj I have forgotten to remove the second declaration. – maciejka Oct 26 '17 at 09:13

1 Answers1

0

We can get data from query string by passing additional parameter through addParams method of ejQuery. Please refer the below KB link for passing parameter to controller method

https://www.syncfusion.com/kb/7865/how-to-pass-additional-parameter-when-using-datamanager-in-grid

If you still face difficulties, please share us some details like whether you are binding data to Grid through datamanager . If not, what are the controls used in your project so that we can proceed further.

Regards, Keerthana.