I haven't used LINQ extensively but the more I use it the more I realize how powerful it can be. Using the LinqDataSource.OrderBy clause is obviously easy if you want to sort from a property on the bounded items but what if you want to sort the items based on a method return? Take this class for instance (please ignore the quirky design - it's just used to emphasize my point):
public class DataItem
{
private string Id { get; set; }
private int SortValue { get; set; }
public DataItem(string id, int sortValue)
{
this.Id = id;
this.SortValue = sortValue;
}
public int GetSortValue()
{
return SortValue;
}
}
Is there a way that I can set the orderby expression on the LinqDataSource so that it uses the value returned from GetSortValue (i.e order by other members than properties) but without altering the DataItem class?