Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Orderby syntax ASC

What is the correct syntax to order by ASC ?

Error 1 The name 'ASC' does not exist in the current context

 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;
like image 956
Sveta26 Avatar asked Dec 03 '11 16:12

Sveta26


People also ask

Is OrderBy ascending or descending?

The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.

How do you ASC in SQL?

If you want to sort some of the data in ascending order and other data in descending order, then you would have to use the ASC and DESC keywords. SELECT * FROM table ORDER BY column1 ASC, column2 DESC; That is how to use the ORDER BY clause in SQL to sort data in ascending order.

What is ASC order in SQL?

The ORDER BY statement in SQL is used to sort the fetched data in either ascending or descending according to one or more columns. By default ORDER BY sorts the data in ascending order. We can use the keyword DESC to sort the data in descending order and the keyword ASC to sort in ascending order.

What is ASC and DESC order?

You can use the ASC and DESC keywords to specify ascending (smallest value first) or descending (largest value first) order. The default order is ascending. For DATE and DATETIME data types, smallest means earliest in time and largest means latest in time.


1 Answers

  • .OrderBy(x => x.City) for ascending order.
  • .OrderByDescending(x => x.City) for descending order
like image 145
Darin Dimitrov Avatar answered Dec 29 '22 11:12

Darin Dimitrov