gpt4 book ai didi

linq - 按语法 ASC 排序

转载 作者:行者123 更新时间:2023-12-02 11:53:11 24 4
gpt4 key购买 nike

按 ASC 排序的正确语法是什么?

错误 1 ​​当前上下文中不存在名称“ASC”

 public IEnumerable<DTO> GetGrid(String ShipNumber)
{
try
{
ORepository rep = new ORepository();
var query = rep.GetAll()
.Where(x => x.SHIP == ShipNumber)
.Orderby (x.City ASC)
.Select(g => new DTO
{
CUSTOMER_NAME = g.CUSTOMER_NAME,
CITY = g.CITY,
SHIP = g.SHIP,
});

return query;

最佳答案

  • .OrderBy(x => x.City) 用于升序排列。
  • .OrderByDescending(x => x.City) 用于降序排列

关于linq - 按语法 ASC 排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8369121/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com