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


C# List.OrderByDescending方法代码示例

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


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

示例1: ConvertList

        private List<Contents> ConvertList(List<Contents> ListContent, int TitleLenght, int IntroLenght, int Limit, string Order, bool IsDesc)
        {
            if ((Limit == null) || (Limit <= 0)) {
                Limit = ListContent.Count;
            }
            if (Limit > ListContent.Count) {
                Limit = ListContent.Count;
            }

            if ((TitleLenght == null) || (TitleLenght <= 0)) {
                TitleLenght = 1000;
            }
            if ((IntroLenght == null) || (IntroLenght <= 0)) {
                IntroLenght = 1000;
            }

            //=========================

            switch (Order) {
                case "Code":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.Code).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.Code).ToList();
                    }
                    break;
                case "DateCreated":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.DateCreated).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.DateCreated).ToList();
                    }
                    break;
                case "DateEdited":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.DateEdited).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.DateEdited).ToList();
                    }
                    break;
                case "CommentCount":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.CommentCount).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.CommentCount).ToList();
                    }
                    break;
                //==============================================================================
                case "ExpireDate":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.ExpireDate).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.ExpireDate).ToList();
                    }
                    break;
                //==============================================================================
                case "ID":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.ID).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.ID).ToList();
                    }
                    break;
                //==============================================================================
                case "LikeCount":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.LikeCount).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.LikeCount).ToList();
                    }
                    break;
                //==============================================================================
                case "PublishDate":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.PublishDate).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.PublishDate).ToList();
                    }
                    break;
                //==============================================================================
                case "ViewCount":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.ViewCount).ToList();
                    }
                    else {
                        ListContent = ListContent.OrderByDescending(a => a.ViewCount).ToList();
                    }
                    break;
                //==============================================================================
                case "Vote":
                    if (IsDesc == false) {
                        ListContent = ListContent.OrderBy(a => a.Vote).ToList();
//.........这里部分代码省略.........
开发者ID:califaxit,项目名称:manhquang,代码行数:101,代码来源:ContentsAction.cs

示例2: ConvertList

        private List<CategoryLevel2> ConvertList(List<CategoryLevel2> ListCategoryLevel2, int InfoLenght, int IntroLenght, int Limit, string Order, bool IsDesc)
        {
            if ((Limit == null) || (Limit <= 0))
            {
                Limit = ListCategoryLevel2.Count;
            }
            if (Limit > ListCategoryLevel2.Count)
            {
                Limit = ListCategoryLevel2.Count;
            }

            if ((InfoLenght == null) || (InfoLenght <= 0))
            {
                InfoLenght = 1000;
            }
            if ((IntroLenght == null) || (IntroLenght <= 0))
            {
                IntroLenght = 1000;
            }

            //=========================

            switch (Order)
            {
                case "Code":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.Code).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.Code).ToList();
                    }
                    break;
                case "CategoryNameLevel2":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.CategoryNameLevel2).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.CategoryNameLevel2).ToList();
                    }
                    break;
                case "Status":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.Status).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.Status).ToList();
                    }
                    break;
                case "Disable":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.Disable).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.Disable).ToList();
                    }
                    break;
                //==============================================================================
                case "IDLang":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.IDLang).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.IDLang).ToList();
                    }
                    break;
                //==============================================================================
                case "ID":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.ID).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.ID).ToList();
                    }
                    break;
                //==============================================================================
                case "Type":
                    if (IsDesc == false)
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderBy(a => a.Type).ToList();
                    }
                    else
                    {
                        ListCategoryLevel2 = ListCategoryLevel2.OrderByDescending(a => a.Type).ToList();
                    }
                    break;
                //==============================================================================
                case "Note":
                    if (IsDesc == false)
//.........这里部分代码省略.........
开发者ID:califaxit,项目名称:manhquang,代码行数:101,代码来源:CategoryLevel2Action.cs


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