当前位置: 首页>>代码示例>>C#>>正文


C# IQueryable.OrderByDescending方法代码示例

本文整理汇总了C#中IQueryable.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryable.OrderByDescending方法的具体用法?C# IQueryable.OrderByDescending怎么用?C# IQueryable.OrderByDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQueryable的用法示例。


在下文中一共展示了IQueryable.OrderByDescending方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddOrder

		public static IQueryable<Album> AddOrder(IQueryable<Album> criteria, AlbumSortRule sortRule, ContentLanguagePreference languagePreference) {

			switch (sortRule) {
				case AlbumSortRule.Name:
					return FindHelpers.AddNameOrder(criteria, languagePreference);
				case AlbumSortRule.ReleaseDate:
					return AddReleaseRestriction(criteria)
						.OrderByDescending(a => a.OriginalRelease.ReleaseDate.Year)
						.ThenByDescending(a => a.OriginalRelease.ReleaseDate.Month)
						.ThenByDescending(a => a.OriginalRelease.ReleaseDate.Day);
				case AlbumSortRule.AdditionDate:
					return criteria.OrderByDescending(a => a.CreateDate);
				case AlbumSortRule.RatingAverage:
					return criteria.OrderByDescending(a => a.RatingAverageInt)
						.ThenByDescending(a => a.RatingCount);
				case AlbumSortRule.NameThenReleaseDate:
					return FindHelpers.AddNameOrder(criteria, languagePreference)
						.ThenBy(a => a.OriginalRelease.ReleaseDate.Year)
						.ThenBy(a => a.OriginalRelease.ReleaseDate.Month)
						.ThenBy(a => a.OriginalRelease.ReleaseDate.Day);
			}

			return criteria;

		}
开发者ID:realzhaorong,项目名称:vocadb,代码行数:25,代码来源:AlbumSearchSort.cs

示例2: GetSorted

        private IQueryable<ProductsListViewModel> GetSorted(IQueryable<ProductsListViewModel> allProducts, string sortOrder)
        {
            ViewBag.CurrentSort = sortOrder;
            ViewBag.DateSortParm = String.IsNullOrEmpty(sortOrder) ? "Date" : "";
            ViewBag.PriceSortParm = sortOrder == "Price" ? "price_desc" : "Price";
            ViewBag.RatingSortParm = sortOrder == "Rating" ? "rating_desc" : "Rating";

            switch (sortOrder)
            {
                case "Rating":
                    allProducts = allProducts.OrderBy(p => p.Rating);
                    break;
                case "rating_desc":
                    allProducts = allProducts.OrderByDescending(p => p.Rating);
                    break;
                case "Price":
                    allProducts = allProducts.OrderBy(p => p.Price);
                    break;
                case "price_desc":
                    allProducts = allProducts.OrderByDescending(p => p.Price);
                    break;
                case "Date":
                    allProducts = allProducts.OrderByDescending(p => p.ReleaseDate);
                    break;
                default:
                    allProducts = allProducts.OrderBy(p => p.ReleaseDate);
                    break;
            }

            return allProducts;
        }
开发者ID:clangelov,项目名称:ASP.NET-MVC-Course-Project,代码行数:31,代码来源:ProductsController.cs

示例3: ApplySort

        public IQueryable<SMSList> ApplySort(IQueryable<SMSList> l)
        {
            if (Pager.Direction == "asc")
            {
                switch (Pager.Sort)
                {
                    case "Sent/Scheduled":
                        l = l.OrderBy(e => e.Created);
                        break;
                    case "From":
                        l = l.OrderBy(e => e.Person.Name);
                        break;
                    case "Title":
                        l = l.OrderBy(e => e.Title);
                        break;
                    case "Include":
                        l = l.OrderBy(e => e.SentSMS);
                        break;
                    case "Exclude":
                        l = l.OrderBy(e => e.SentNone);
                        break;
                }
            }
            else
            {
                switch (Pager.Sort)
                {
                    case "Sent/Scheduled":
                        l = l.OrderByDescending(e => e.Created);
                        break;
                    case "From":
                        l = l.OrderByDescending(e => e.Person.Name);
                        break;
                    case "Title":
                        l = l.OrderByDescending(e => e.Title);
                        break;
                    case "Include":
                        l = l.OrderByDescending(e => e.SentSMS);
                        break;
                    case "Exclude":
                        l = l.OrderByDescending(e => e.SentNone);
                        break;
                    default:
                        l = l.OrderByDescending(e => e.Created);
                        break;
                }
            }

            return l;
        }
开发者ID:stevesloka,项目名称:bvcms,代码行数:50,代码来源:SMSModel.cs

示例4: ApplyOrdering

 IQueryable<Product> ApplyOrdering(IQueryable<Product> products, string direction)
 {
     if (products == null)
         return null;
     
     return direction == "desc" ? products.OrderByDescending(p => p.Id) : products.OrderBy(p => p.Id);
 }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:7,代码来源:SiteModel.cs

示例5: ApplyFilter

        public IQueryable<MarketOrder> ApplyFilter(IQueryable<MarketOrder> query)
        {
            query = query.Where(pos =>
                               (filterMagic == null || filterMagic.Value == pos.Magic) &&
                               (filterSide == null || filterSide.Value == pos.Side) &&
                               (string.IsNullOrEmpty(filterComment) ||
                                pos.Comment.Contains(filterComment)) &&
                               (string.IsNullOrEmpty(filterExpertComment) ||
                                pos.ExpertComment.Contains(filterExpertComment)) &&
                               (string.IsNullOrEmpty(filterTicker) ||
                                pos.Symbol.Contains(filterTicker)) &&
                               (filterTimeEnterStartsWith == null ||
                                pos.TimeEnter >= filterTimeEnterStartsWith.Value) &&
                               (filterTimeEnterEndsWith == null ||
                                pos.TimeEnter <= filterTimeEnterEndsWith.Value) &&
                               (filterTimeExitStartsWith == null ||
                                pos.TimeExit >= filterTimeExitStartsWith) &&
                               (filterTimeExitEndsWith == null ||
                                pos.TimeExit <= filterTimeExitEndsWith));

            query = (sortAscending ? query.OrderBy(p => sortByTimeEnter ? p.TimeEnter : p.TimeExit)
                                 : query.OrderByDescending(p => sortByTimeEnter ? p.TimeEnter : p.TimeExit))
                                .Take(takeCount);
            return query;
        }
开发者ID:johnmensen,项目名称:TradeSharp,代码行数:25,代码来源:OrderFilterAndSortOrder.cs

示例6: orderCustomers

 private IQueryable<Customer> orderCustomers(IQueryable<Customer> customers, string sortColumn, string sortOrder)
 {
     if (sortColumn == "CustomerId")
         return (sortOrder == "desc") ? customers.OrderByDescending(c => c.CustomerID) : customers.OrderBy(c => c.CustomerID);
     if (sortColumn == "Name")
         return (sortOrder == "desc") ? customers.OrderByDescending(c=>c.FirstName) : customers.OrderBy(c=>c.FirstName);
     if (sortColumn == "Company")
        return (sortOrder == "desc")? customers.OrderByDescending(c=>c.CompanyName) : customers.OrderBy(c=>c.CompanyName);
     if (sortColumn == "EmailAddress")
         return (sortOrder == "desc") ? customers.OrderByDescending(c => c.EmailAddress) : customers.OrderBy(c => c.EmailAddress);
     if (sortColumn == "Last Modified")
         return (sortOrder == "desc") ? customers.OrderByDescending(c => c.ModifiedDate) : customers.OrderBy(c => c.ModifiedDate);
     if (sortColumn == "Telephone")
         return (sortOrder == "desc") ? customers.OrderByDescending(c => c.Phone) : customers.OrderBy(c => c.Phone);
     return customers;
 }
开发者ID:reharik,项目名称:MvcJqGrid,代码行数:16,代码来源:Repository.cs

示例7: Translate

            public IQueryable<MediaContent> Translate(IExpression expression, IQueryable<MediaContent> contentQueryable)
            {
                this.Visite(expression);

                contentQueryable = contentQueryable.Where(this.LinqExpression);

                if (this.OrderExprssion != null)
                {
                    if (!this.OrderDesc)
                    {
                        contentQueryable = contentQueryable.OrderBy(this.OrderExprssion);
                    }
                    else
                    {
                        contentQueryable = contentQueryable.OrderByDescending(this.OrderExprssion);
                    }
                }

                if (Skip.HasValue)
                {
                    contentQueryable = contentQueryable.Skip(Skip.Value);
                }
                if (Take.HasValue)
                {
                    contentQueryable = contentQueryable.Take(Take.Value);
                }

                return contentQueryable;
            }
开发者ID:Godoy,项目名称:CMS,代码行数:29,代码来源:MediaContentProvider.cs

示例8: CreateFilteredRequestTable

        public static MvcHtmlString CreateFilteredRequestTable(this HtmlHelper helper, IQueryable<FilteredRequestRecord> filteredRequestRecords, Localizer T)
        {
            StringBuilder sb = new StringBuilder();

            if (filteredRequestRecords == null || !filteredRequestRecords.Any())
            {
                sb.AppendLine(T("No requests are filtered yet.").Text);
            }
            else
            {
                sb.AppendLine("<table><tr>");
                sb.AppendFormat("<th>{0}</th>", T("Request time"));
                sb.AppendFormat("<th>{0}</th>", T("Url"));
                sb.AppendFormat("<th>{0}</th>", T("User Host Address"));
                sb.AppendFormat("<th>{0}</th>", T("User Agent"));
                sb.AppendLine("</tr>");

                foreach (FilteredRequestRecord filteredRequest in filteredRequestRecords.OrderByDescending(r => r.RequestTime))
                {
                    sb.AppendLine("<tr>");
                    sb.AppendFormat("<td>{0}</td>", filteredRequest.RequestTime);
                    sb.AppendFormat("<td>{0}</td>", filteredRequest.Url);
                    sb.AppendFormat("<td>{0}</td>", filteredRequest.UserHostAddress);
                    sb.AppendFormat("<td>{0}</td>", filteredRequest.UserAgent);
                    sb.AppendLine("</tr>");
                }
                sb.AppendLine("</table>");
            }
            return new MvcHtmlString(sb.ToString());
        }
开发者ID:rijkshuisstijl,项目名称:Rijkshuisstijl.UrlProtector,代码行数:30,代码来源:UrlProtectorHtmlHelper.cs

示例9: GetListUsers

        // GET: GetListUserList
        public PartialViewResult GetListUsers(string SortOrder, string CurrentFilter, string SearchString, int? Page = 1)
        {
            int pageSize = 10;

            ViewBag.CurrentSort = SortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(SortOrder) ? "Name_desc" : "";
            ViewBag.UsernameSortParm = SortOrder == "Username" ? "Username_desc" : "Username";
            ViewBag.EmailSortParm = SortOrder == "Email" ? "Email_desc" : "Email";

            if (SearchString != null)
            {
                Page = 1;
            }
            else
            {
                SearchString = CurrentFilter;
            }

            ViewBag.CurrentFilter = SearchString;

            UserList = UOW.UserRepository.Get();

            if (!String.IsNullOrEmpty(SearchString))
            {
                UserList = UserList.Where(s => s.Name.Contains(SearchString)
                                           || s.Username.Contains(SearchString)
                                           || s.EmailAdress.Contains(SearchString));
            }

            ViewBag.Count = UserList.Count();

            switch (SortOrder)
            {
                case "Name_desc":
                    UserList = UserList.OrderByDescending(s => s.Name);
                    break;
                case "Username":
                    UserList = UserList.OrderBy(s => s.Username);
                    break;
                case "Username_desc":
                    UserList = UserList.OrderByDescending(s => s.Username);
                    break;
                case "Email":
                    UserList = UserList.OrderBy(s => s.EmailAdress);
                    break;
                case "Email_desc":
                    UserList = UserList.OrderByDescending(s => s.EmailAdress);
                    break;
                default:
                    UserList = UserList.OrderBy(s => s.Name);
                    break;
            }

            int pageNumber = (Page ?? 1);

            return PartialView("GetListUsers",UserList.ToList().ToPagedList(pageNumber, pageSize));
        }
开发者ID:marquesdasilva,项目名称:UserManager_v02,代码行数:58,代码来源:WBUserListController.cs

示例10: Sort

        protected IQueryable<ProductViewModel> Sort(IQueryable<ProductViewModel> products, string sortBy, string sortOrder)
        {
            if (sortBy == SortByDefault)
            {
                if (sortOrder == SortOrderDefault)
                    return products.OrderByDescending(p => p.Likes.Count);
                else
                    return products.OrderBy(p => p.Likes.Count);
            }

            if (sortBy == "Price")
            {
                if (sortOrder == SortOrderDefault)
                    return products.OrderByDescending(p => p.Price);
            }

            return products.OrderBy(p => p.Price);
        }
开发者ID:TeeeeeC,项目名称:TelerikAcademy2015-2016,代码行数:18,代码来源:BaseController.cs

示例11: doSort

        /// <summary>
        /// Private helper method set and return the sorted workouts
        /// </summary>
        /// <param name="workouts">The base workout query result</param>
        /// <param name="sortBy">Indicates the sort order</param>
        /// <param name="session">The Session object to get or set variables from/to</param>
        /// <param name="viewBag">The viewBag object to pass the set variables back to the view with</param>
        /// <returns>The sorted workouts</returns>
        public static IQueryable<workout> doSort(IQueryable<workout> workouts, string sortBy, HttpSessionStateBase session, dynamic viewBag)
        {
            if (!String.IsNullOrEmpty(sortBy))
            {
                SessionVariableManager.setSessionFromSort(session, sortBy);
            }
            else
            {
                sortBy = SessionVariableManager.setSortFromSession(session, sortBy);
            }

            viewBag.NameSortParam = (sortBy == "name") ? "name_desc" : "name";
            viewBag.DateSortParam = (sortBy == "date") ? "date_desc" : "date";
            viewBag.CategorySortParam = (sortBy == "category") ? "category_desc" : "category";
            viewBag.UserSortParam = (sortBy == "user") ? "user_desc" : "user";
            viewBag.DescriptionSortParam = (sortBy == "description") ? "description_desc" : "description";

            switch (sortBy)
            {
                case "name":
                    workouts = workouts.OrderBy(w => w.name);
                    break;
                case "name_desc":
                    workouts = workouts.OrderByDescending(w => w.name);
                    break;
                case "date":
                    workouts = workouts.OrderBy(w => w.created_at);
                    break;
                case "date_desc":
                    workouts = workouts.OrderByDescending(w => w.created_at);
                    break;
                case "category":
                    workouts = workouts.OrderBy(w => w.category.name);
                    break;
                case "category_desc":
                    workouts = workouts.OrderByDescending(w => w.category.name);
                    break;
                case "user":
                    workouts = workouts.OrderBy(w => w.user.username);
                    break;
                case "user_desc":
                    workouts = workouts.OrderByDescending(w => w.user.username);
                    break;
                case "description":
                    workouts = workouts.OrderBy(w => w.description);
                    break;
                case "description_desc":
                    workouts = workouts.OrderByDescending(w => w.description);
                    break;
                default:
                    workouts = workouts.OrderByDescending(w => w.name);
                    break;
            }

            return workouts;
        }
开发者ID:marinaushakova,项目名称:GoFit,代码行数:64,代码来源:WorkoutSortSearch.cs

示例12: OrderBySolutions

        public IOrderedQueryable<Quiz> OrderBySolutions(IQueryable<Quiz> quizzesQuery, DateRange range)
        {
            var result = quizzesQuery
                .OrderByDescending(q => q.Solutions.Count(
                    s => range.From <= s.CreatedOn && s.CreatedOn <= range.To))
                .ThenByDescending(q => q.Solutions.Count)
                .ThenBy(q => q.CreatedOn);

            return result;
        }
开发者ID:kidroca,项目名称:project-quiz-mvc,代码行数:10,代码来源:QuizzesRankingService.cs

示例13: SortDogs

        protected static IEnumerable<Dog> SortDogs(IQueryable<Dog> dogs, string sortBy = null)
        {
            IOrderedQueryable<Dog> orderedDogs;

            switch (sortBy)
            {
                case SearchSortOptions.PRICE_HIGHEST:
                    orderedDogs=dogs.OrderByDescending(SortExpressions.PriceOrder);
                    break;
                case SearchSortOptions.PRICE_LOWEST:
                    orderedDogs=dogs.OrderBy(SortExpressions.PriceOrder);
                    break;
                default:
                    orderedDogs=dogs.OrderByDescending(SortExpressions.CreatedOnOrder);
                    break;
            }

            return orderedDogs;
        }
开发者ID:jegglestone,项目名称:Animal-Store,代码行数:19,代码来源:DogsSearchAndSortStrategy.cs

示例14: Sort

        private IQueryable<Product> Sort(IQueryable<Product> products, SortField sortField, SortDirection sortDirection)
        {
            if (sortField == SortField.Name)
            {
                if (sortDirection == SortDirection.Up)
                {
                    return products.OrderBy(o => o.Category.Name);
                }
                else
                {
                    return products.OrderByDescending(o => o.Category.Name);
                }
            }

            if (sortField == SortField.Price)
            {
                if (sortDirection == SortDirection.Up)
                {
                    return products.OrderBy(o => o.Price);
                }
                else
                {
                    return products.OrderByDescending(o => o.Price);
                }
            }

            if (sortField == SortField.Title)
            {
                if (sortDirection == SortDirection.Up)
                {
                    return products.OrderBy(o => o.Title);
                }
                else
                {
                    return products.OrderByDescending(o => o.Title);
                }
            }

            // Should not reach here, but return products for compiler
            return products;
        }
开发者ID:hjgraca,项目名称:PartsUnlimited,代码行数:41,代码来源:StoreManagerController.cs

示例15: OrderProducts

 private static IQueryable<Product> OrderProducts(IQueryable<Product> products, string sortOrder)
 {
     switch (sortOrder)
     {
         case "desc":
             return products.OrderByDescending(p => p.Price).ThenBy(p => p.Name).AsQueryable();
         case "asc":
             return products.OrderBy(p => p.Price).ThenBy(p => p.Name).AsQueryable();
         default: // "abc"
             return products.OrderBy(p => p.Name).AsQueryable();
     }
 }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:12,代码来源:CatalogueModel.cs


注:本文中的IQueryable.OrderByDescending方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。