我有以下查询:
var accounts =
from account in context.Accounts
from guranteer in account.Gurantors
select new AccountsReport
{
CreditRegistryId = account.CreditRegistryId,
AccountNumber = account.AccountNo,
DateOpened = account.DateOpened,
};
return accounts.AsEnumerable()
.Select((account, index) => new AccountsReport()
{
RecordNumber = FormattedRowNumber(account, index + 1),
CreditRegistryId = account.CreditRegistryId,
AccountNumber = FormattedAccountNumber(account.AccountType, account.AccountNumber)}).OrderByDescending(c => c.StateChangeDate);
It works fine except one problem and that is it returns records number in reverse order like 3, 2,1 because of .OrderByDescending(c => c.StateChangeDate);
我是否可以按升序排列显示记录编号,同时保持记录的降序。
请建议。
由于
答案 0 :(得分:1)
尝试使用RecordNumber
上的OrderBy,然后StateChangeDate
上的ThenByDescending
.OrderBy(c => c.RecordNumber).ThenByDescending(c => c.StateChangeDate);