按降序排序主键不使用组

时间:2018-05-06 11:46:58

标签: c# entity-framework linq

我已按QueriedTransactionList排序结果TTransactionID,然后按BatchID进行分组。出于某种原因,descending的排序无效。它仍然按升序排序TTransactionID

QueriedTransactionList = db.Transactions.OrderByDescending(x => x.TTransactionID).GroupBy(x => x.BatchID).Select(x => x.FirstOrDefault()).ToList();

TransactionViewModel TransactionViewModel = new TransactionViewModel();
            List<TransactionViewModel> TransactionDataList = QueriedTransactionList.Select(x => new TransactionViewModel
            {
                TTransactionID = x.TTransactionID,
                BatchID = x.BatchID,
                TransactionDateTime = x.TransactionDateTime,
                TransactionStatus = x.TransactionStatus,
                TaxPayerName = x.Card.TaxPayer.TaxPayerName,
                TaxPayerEmail = x.Card.TaxPayer.TaxPayerEmail,
                TaxPayerTIN = x.Card.TaxPayer.TaxPayerTIN,
                DispatchBy = x.User.UserName,
                DestinationPort = x.Card.Port.PortName,
                BatchCards = Helper.GetBatchQtyByBatchID(x.BatchID)
            }).ToList();

0 个答案:

没有答案