Sort collection within collection using Linq
Posted
by user327066
on Stack Overflow
See other posts from Stack Overflow
or by user327066
Published on 2010-04-27T16:55:46Z
Indexed on
2010/04/27
17:03 UTC
Read the original article
Hit count: 203
Hi, I have a one-to-many Linq query and I would like to sort on a property within the "many" collection. For example in the pseudo-code below, I am returned a List from the Linq query but I would like to sort / order the Products property based on the SequenceNumber property of the Product class. How can I do this? Any information is appreciated. Thanks.
class Order
{
int OrderId;
List<Product> Products;
}
class Product
{
string name;
int SequenceNumber;
}
© Stack Overflow or respective owner