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


C# SortDirection.Equals方法代码示例

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


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

示例1: SortAutomobiles

 public static IQueryable<Automobile> SortAutomobiles(IQueryable<Automobile> automobiles,
             string sortExpression, SortDirection sortDirection)
 {
     bool ascending = sortDirection.Equals(SortDirection.Ascending);
     IQueryable<Automobile> sortedAutomobiles = automobiles;
     if (sortExpression.Equals(CarServiceConstants.AUTOMOBILE_ID_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedAutomobiles = automobiles.OrderBy(auto => auto.AutomobileId);
         }
         else
         {
             sortedAutomobiles = automobiles.OrderByDescending(auto => auto.AutomobileId);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.AUTOMOBILE_VIN_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedAutomobiles = automobiles.OrderBy(auto => auto.Vin);
         }
         else
         {
             sortedAutomobiles = automobiles.OrderByDescending(auto => auto.Vin);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.AUTOMOBILE_CHASSIS_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedAutomobiles = automobiles.OrderBy(auto => auto.ChassisNumber);
         }
         else
         {
             sortedAutomobiles = automobiles.OrderByDescending(auto => auto.ChassisNumber);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.AUTOMOBILE_MAKE_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedAutomobiles = automobiles.OrderBy(auto => auto.Make);
         }
         else
         {
             sortedAutomobiles = automobiles.OrderByDescending(auto => auto.Make);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.AUTOMOBILE_MODEL_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedAutomobiles = automobiles.OrderBy(auto => auto.Model);
         }
         else
         {
             sortedAutomobiles = automobiles.OrderByDescending(auto => auto.Model);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.AUTOMOBILE_OWNER_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedAutomobiles = automobiles.OrderBy(auto => auto.Owner);
         }
         else
         {
             sortedAutomobiles = automobiles.OrderByDescending(auto => auto.Owner);
         }
     }
     return sortedAutomobiles;
 }
开发者ID:TelerikAcademy,项目名称:QA-Academy,代码行数:73,代码来源:SortingUtility.cs

示例2: SortUsers

    public static IEnumerable<CarServiceUser> SortUsers(List<CarServiceUser> users,
        string sortExpression, SortDirection sortDirection)
    {
        bool ascending = sortDirection.Equals(SortDirection.Ascending);
        IEnumerable<CarServiceUser> sortedUsers = null;
        if (sortExpression.Equals(CarServiceConstants.USER_NAME_SORT_EXPRESSION))
        {
            if (ascending)
            {
                sortedUsers = users.OrderBy(user => user.UserName);
            }
            else
            {
                sortedUsers = users.OrderByDescending(user => user.UserName);
            }

        }
        else if (sortExpression.Equals(CarServiceConstants.USER_EMAIL_SORT_EXPRESSION))
        {
            if (ascending)
            {
                sortedUsers = users.OrderBy(user => user.Email);
            }
            else
            {
                sortedUsers = users.OrderByDescending(user => user.Email);
            }
        }
        else if (sortExpression.Equals(CarServiceConstants.USER_FIRST_NAME_SORT_EXPRESSION))
        {
            if (ascending)
            {
                sortedUsers = users.OrderBy(user => user.FirstName);
            }
            else
            {
                sortedUsers = users.OrderByDescending(user => user.FirstName);
            }
        }
        else if (sortExpression.Equals(CarServiceConstants.USER_LAST_NAME_SORT_EXPRESSION))
        {
            if (ascending)
            {
                sortedUsers = users.OrderBy(user => user.LastName);
            }
            else
            {
                sortedUsers = users.OrderByDescending(user => user.LastName);
            }
        }
        else if (sortExpression.Equals(CarServiceConstants.USER_ACTIVE_SORT_EXPRESSION))
        {
            if (ascending)
            {
                sortedUsers = users.OrderBy(user => user.IsActive);
            }
            else
            {
                sortedUsers = users.OrderByDescending(user => user.IsActive);
            }
        }
        return sortedUsers;
    }
开发者ID:TelerikAcademy,项目名称:QA-Academy,代码行数:63,代码来源:SortingUtility.cs

示例3: SortRepairCards

 public static IQueryable<RepairCard> SortRepairCards(IQueryable<RepairCard> repairCards,
     string sortExpression, SortDirection sortDirection)
 {
     bool ascending = sortDirection.Equals(SortDirection.Ascending);
     IQueryable<RepairCard> sortedCards;
     if (sortExpression.Equals(CarServiceConstants.REPAIR_CARD_ID_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedCards = repairCards.OrderBy(card => card.CardId);
         }
         else
         {
             sortedCards = repairCards.OrderByDescending(card => card.CardId);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.REPAIR_CARD_CHASSIS_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedCards = repairCards.OrderBy(card => card.Automobile.ChassisNumber);
         }
         else
         {
             sortedCards = repairCards.OrderByDescending(card => card.Automobile.ChassisNumber);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.REPAIR_CARD_Vin_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedCards = repairCards.OrderBy(card => card.Automobile.Vin);
         }
         else
         {
             sortedCards = repairCards.OrderByDescending(card => card.Automobile.Vin);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.REPAIR_CARD_START_DATE_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedCards = repairCards.OrderBy(card => card.StartRepair);
         }
         else
         {
             sortedCards = repairCards.OrderByDescending(card => card.StartRepair);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.REPAIR_CARD_FINISH_DATE_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedCards = repairCards.OrderBy(card => card.FinishRepair);
         }
         else
         {
             sortedCards = repairCards.OrderByDescending(card => card.FinishRepair);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.REPAIR_CARD_PRICE_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedCards = repairCards.OrderBy(card => card.CardPrice);
         }
         else
         {
             sortedCards = repairCards.OrderByDescending(card => card.CardPrice);
         }
     }
     else
     {
         sortedCards = repairCards;
     }
     return sortedCards;
 }
开发者ID:TelerikAcademy,项目名称:QA-Academy,代码行数:77,代码来源:SortingUtility.cs

示例4: SortSpareParts

 public static IQueryable<SparePart> SortSpareParts(IQueryable<SparePart> spareParts,
             string sortExpression, SortDirection sortDirection)
 {
     bool ascending = sortDirection.Equals(SortDirection.Ascending);
     IQueryable<SparePart> sortedSpareParts = spareParts;
     if (sortExpression.Equals(CarServiceConstants.SPARE_PART_ID_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedSpareParts = spareParts.OrderBy(part => part.PartId);
         }
         else
         {
             sortedSpareParts = spareParts.OrderByDescending(part => part.PartId);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.SPARE_PART_NAME_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedSpareParts = spareParts.OrderBy(part => part.Name);
         }
         else
         {
             sortedSpareParts = spareParts.OrderByDescending(part => part.Name);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.SPARE_PART_PRICE_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedSpareParts = spareParts.OrderBy(part => part.Price);
         }
         else
         {
             sortedSpareParts = spareParts.OrderByDescending(part => part.Price);
         }
     }
     else if (sortExpression.Equals(CarServiceConstants.SPARE_PART_ACTIVE_SORT_EXPRESSION))
     {
         if (ascending)
         {
             sortedSpareParts = spareParts.OrderBy(part => part.IsActive);
         }
         else
         {
             sortedSpareParts = spareParts.OrderByDescending(part => part.IsActive);
         }
     }
     return sortedSpareParts;
 }
开发者ID:TelerikAcademy,项目名称:QA-Academy,代码行数:51,代码来源:SortingUtility.cs

示例5: directionToString

 private string directionToString(SortDirection direction)
 {
     return direction.Equals(SortDirection.ASC) ? "ASC" : "DESC";
 }
开发者ID:Edhendil,项目名称:MonoLiteOrm,代码行数:4,代码来源:OrderByElement.cs


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