var hierarchy = new StaticPageCollection();
hierarchy = GetMyCollection()//this will populate from database
This is how I create my "StaticPageCollection()"
public class StaticPage : BaseEntity
{
public string Name{get;set;}
public int LoadOrder{get;set;}
}
public class StaticPageCollection : BaseEntityCollection<StaticPage>
{
}
public abstract class BaseEntityCollection<T> : List<T> where T : BaseEntity, new()
{
}
public abstract class BaseEntity
{
}
My Question is how would I sort this by LoadOrder??
ricc
Member
727 Points
213 Posts
Sorting custom collection
May 25, 2012 03:59 PM|LINK
Hi I have a custom collection as below:
var hierarchy = new StaticPageCollection();
hierarchy = GetMyCollection()//this will populate from database
This is how I create my "StaticPageCollection()"
public class StaticPage : BaseEntity
{
public string Name{get;set;}
public int LoadOrder{get;set;}
}
public class StaticPageCollection : BaseEntityCollection<StaticPage>
{
}
public abstract class BaseEntityCollection<T> : List<T> where T : BaseEntity, new()
{
}
public abstract class BaseEntity
{
}
My Question is how would I sort this by LoadOrder??
Thanks
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: Sorting custom collection
May 25, 2012 06:12 PM|LINK
someCollection = hierarchy.OrderBy(Function(item) item.<propertyToSortBy>).ToList()
It's what I use to sort my List(Of <object>)
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!