0
订购我似乎遇到了问题排序作为其唯一的排序第一位LINQ的只是第一个数字
int storageCapacity;
IEnumerable<ProductStorageCapacity> items;
if (int.TryParse(filter["StorageCapacity"], out storageCapacity) && storageCapacity > 0)
items = await context.ProductStorageCapacities
.Where(ps => ps.StorageCapacity == storageCapacity)
.OrderByDescending(ps => ps.StorageCapacity).ToListAsync();
else items = await context.ProductStorageCapacities
.OrderBy(ps => ps.StorageCapacity).ToListAsync();
任何帮助吗?
您只选择具有特定“StorageCapacity”的项目,然后按该值排序。这是毫无意义的,因为所有的项目都会有相同的值,所以你会得到一个任意的顺序。 –
根据@Tim的评论,我假设你在问'else'的情况。什么是'StorageCapacity'的类型?此外,使用“ToListAsync”并立即“等待”结果的意义何在? – slawekwin
public int StorageCapacity {get;组; } - 这是一个int – momo003