无论我做什么,我似乎无法按发票名称对列表进行排序。 我有一个客户端类,其中包含Igolection of Invoices
我的Repoistory
public Client FindClientById(string id)
{
Client client = RepositorySet.Include("Account").Include("Invoice").FirstOrDefault(c => c.Id == id && !c.IsDeleted);
return client;
}
在我的控制器上
Client clientToEdit = _clientService.FindClientAndInvoicesById(id);
List<Invoice> SortedList = clientToEdit.invoices.OrderBy(o => o.Name).ToList();
我做错了什么?
答案 0 :(得分:1)
试试这个
SortedList.OrderBy(x => x.field)
或
List<Invoice> SortedList = clientToEdit.invoices.ToList().OrderBy(o => o.Name);