Reputation: 541
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;
Upvotes: 16
Views: 31461
Reputation: 137
IEnumerable<t_HomeRequets> homeRequets = cnx.t_HomeRequets
.Where(x => x.HomeRequestId > DeletedId && x.BuildingId== BuildingId)
.OrderByDescending(s => s.HomeRequestId)
.AsEnumerable<t_HomeRequets>();
Outputs an IEnumerable set you can create this set with a var or any type
Upvotes: 0
Reputation: 11
Use this query when you use Distinct.
var result = ctx.tblCity.AsNoTracking()
.Where(s => s.City== "Chennai")
.Select(s => new Area { Name = s.AreaName})
.Distinct().OrderBy(s => s.Name).ToList();
It worked for me.
Upvotes: 1
Reputation: 1039498
.OrderBy(x => x.City)
for ascending order..OrderByDescending(x => x.City)
for descending orderUpvotes: 56