Hi, my application has the following code to add a ToSortedList
extension method on any IEnumberable:

public class SortedList<T, TResult> : List<T> {
    public SortedList(IEnumerable<T> source, Expression<Func<T,
TResult>> sortBy, SortDirection sortDirection) {
        Initialize(source is IQueryable<T> ? source as IQueryable<T> :
source.AsQueryable(), sortBy, sortDirection);
    }

    protected void Initialize(IQueryable<T> source, Expression<Func<T,
TResult>> sortBy, System.Web.UI.WebControls.SortDirection
sortDirection) {
        AddRange(sortDirection == SortDirection.Ascending ?
source.OrderBy(sortBy) : source.OrderByDescending(sortBy));
    }
}

public static class SortingExtensions {
    public static SortedList<T, TResult> ToSortedList<T, TResult>(this
IEnumerable<T> source, Expression<Func<T, TResult>> sortBy,
SortDirection sortDirection) {
        return new SortedList<T, TResult>(source, sortBy,
sortDirection);
    }
}

In the old LINQ provider (on top of NHibernate 2.1) i could then say:

session.Linq<Article>().ToSortedList(a => a.Date,
SortDirection.Ascending);

However using the new in-built LINQ provider in NHibernate 3 (change
Linq to Query above) this does not work and the following error is
thrown:

"Specified method is not supported." - within the Initialize method

I'd really appreciate it if someone could show me how this could be
done.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to