I am trying to call OrderBy() using a custom IComparer on a SubSonic IQueryable like so:
IQueryable<FooObject> sortedFoos =
FooObject.All()
.OrderBy(f => f, new FooObjectComparer());
However when I then try to enumerate over sortedFoos or create a PagedList<FooObject> using it, I get a System.Exception: 'The LINQ expression node of type MemberInit is not supported'.
Here is the implementation for FooObjectComparer:
public class FooObjectComparer : IComparer<FooObject>
{
public FooObjectComparer() {}
public int Compare(FooObject x, FooObject y)
{
return x.MyProperty.CompareTo(y.MyProperty);
}
}
(This is a simple implementation for debugging purposes. The actual implementation will be more complex).
What am I missing here?