public ActionResult Exemple3()
        {
            ViewBag.Message = "Mapping a IQueryable";
            //this exemple show how map a IQueryable of customer to List of customerModel
            ExempleCustomer exemple3 = new ExempleCustomer();

            var result = exemple3.GetCustomers();
            //Map to list with using the select extention of the mapper
            var model = result.Select <Customer, CustomerModel>().ToList();

            return(View(model));
        }
        public ActionResult Exemple4(SortedAndPagingCustomerModel model)
        {
            ViewBag.Message = "Exemple for OrderBy extentions";
            //this exemple show how map a IQueryable of customer with the OrderBy extention
            ExempleCustomer exemple4 = new ExempleCustomer();

            model.PageIndex = model.PageIndex == 0 ? 0 : model.PageIndex - 1;
            var result    = exemple4.GetCustomers();
            var skipValue = model.PageIndex * nbItemPerPage;

            if (skipValue < 0)
            {
                skipValue = nbItemPerPage;
            }
            //ThenBy and ThenByDescending are also implemented
            model.NumberOfPage = Math.Round(Convert.ToDouble(result.Count() / nbItemPerPage));
            if (!string.IsNullOrEmpty(model.SortDirection))
            {
                if (model.SortDirection == "ascending")
                {
                    //this create a sql request include ORDER BY, see the console output to see the request.
                    model.Customers = result
                                      .OrderBy <Customer, CustomerModel>(model.SortField)
                                      .Skip(skipValue)
                                      .Take(nbItemPerPage)
                                      .Select <Customer, CustomerModel>()
                                      .ToList();
                }
                else
                {
                    model.Customers = result
                                      .OrderByDescending <Customer, CustomerModel>(model.SortField)
                                      .Skip(skipValue)
                                      .Take(nbItemPerPage)
                                      .Select <Customer, CustomerModel>()
                                      .ToList();
                }
            }
            else
            {
                model.Customers = result
                                  .OrderBy(x => x.CustomerId)
                                  .Skip(skipValue)
                                  .Take(nbItemPerPage)
                                  .Select <Customer, CustomerModel>()
                                  .ToList();
            }
            return(View(model));
        }
        public ActionResult Exemple4()
        {
            //Default page
            ViewBag.Message = "Exemple for OrderBy extentions";
            //this exemple show how map a IQueryable of customer to List of customerModel
            ExempleCustomer exemple4 = new ExempleCustomer();

            var result = exemple4.GetCustomers();

            SortedAndPagingCustomerModel model = new SortedAndPagingCustomerModel();

            model.PageIndex    = 0;
            model.Customers    = result.Select <Customer, CustomerModel>().Take(nbItemPerPage).ToList();
            model.NumberOfPage = Math.Round(Convert.ToDouble(result.Count() / nbItemPerPage));
            return(View(model));
        }