Home  /  Questions  /  Question



0   0
Dec 15, 2016


Webapi for PatternInAction , change the viewmodel from ActionResult to IQueryable type

Hi all

I am studying the PatternInAction project and i would like how to convert the presentation layer from Mvc to Webapi

May i know how to change the ViewModel in Mvc project to IQueryable ? 

For example, the below function, it returns in ActionResult, but how do i may OrdersModel to be IQueryable? 

Look forward your favourite reply. Thanks a lot


Regards
Billy
[HttpGet]
        public ActionResult Orders(string sort = "memberId", string order = "desc")
        {
            ViewBag.Crumbs = new List<BreadCrumb>();
            ViewBag.Crumbs.Add(new BreadCrumb { Title = "home", Url = "/" });
            ViewBag.Crumbs.Add(new BreadCrumb { Title = "administration", Url = "/administration" });
            ViewBag.Crumbs.Add(new BreadCrumb { Title = "orders" });

            ViewBag.Menu = "orders";

            var model = new OrdersModel();
            var members = service.GetMembersWithOrderStatistics(sort + " " + order);
            var memberModels = Mapper.Map<List<Member>, List<MemberModel>>(members);
            model.Members = new SortedList<MemberModel>(memberModels, sort, order);

            return View(model);
        }