Reputation: 5341
Whatever I do I cant seem to sort a list by invoice name. I have a client class that contains a Icollection of Invoices
My Repoistory
public Client FindClientById(string id)
{
Client client = RepositorySet.Include("Account").Include("Invoice").FirstOrDefault(c => c.Id == id && !c.IsDeleted);
return client;
}
On My controller
Client clientToEdit = _clientService.FindClientAndInvoicesById(id);
List<Invoice> SortedList = clientToEdit.invoices.OrderBy(o => o.Name).ToList();
What am I doing wrong?
Upvotes: 0
Views: 38
Reputation: 3261
Try this
SortedList.OrderBy(x => x.field)
or
List<Invoice> SortedList = clientToEdit.invoices.ToList().OrderBy(o => o.Name);
Upvotes: 1