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
3
  • 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. Commented Oct 26, 2017 at 9:10
  • 1
    Looks like a dupe of stackoverflow.com/q/12298409/728795 Commented Oct 26, 2017 at 9:12
  • Sorry @ErikKralj I have forgotten to remove the second declaration. Commented Oct 26, 2017 at 9:13

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.