Dear all,
i have an TList<Entity> object
TList<DetaildCodes> entityDetaildCodes = new TList<DetaildCodes>(); DetaildCodesService buzDetaildCodes = new DetaildCodesService();
entityDetaildCodes = buzDetaildCodes.GetAll();
how to sort entityDetaildCodes object
thank you
Hello,
You could update the stored procedure to order by a specfic column. You could also use a builder and build your query or you could sort your list like the following:
TList<Product> products = DataRepository.ProductProvider.GetAll();products.Sort("Name");foreach (Product product in products){Console.WriteLine(product.Name);}
Thanks-Blake Niemyjski
Blake Niemyjski CodeSmith Tools, LLC. Software Development Engineer Blog: http://windowscoding.com/blogs/blake/ .NetTiers team | Visit http://www.nettiers.com
public class CustomProductComparer : System.Collections.Generic.IComparer<Product>{ public int Compare(Product x, Product y) { return y.Name.CompareTo(x.Name); }}TList<Product> products = DataRepository.ProductProvider.GetAll();products.Sort(new CustomProductComparer());foreach (Product product in products){ Console.WriteLine(product.Name);}If it doesn't work, switch the x and y around.
Slight variation using const string instead of string literal for the column name.TList<Product> products = DataRepository.ProductProvider.GetAll();products.Sort(ProductColumn.Name.ToString());foreach (Product product in products){ Console.WriteLine(product.Name);}
Ryan, could you please tell me how to sort TList in descending order. Many thanks,.
Maddy.