문제

I'm using RadGrid in a SL app using RIA services / MVVM

In my Viewmodel I have an IEnumerable collection that works fine when simply exposing the collection:

public IEnumerable<Orders> OrderList
    {
        get
        {
            return datacontext.Orders;
        }
    }

However, when I try to sort the collection before it's bound (as follows) I get an error "Message: System.typeaccessexception Attempt by method DynamicClass.lambda ..... " and the application hangs:

public IEnumerable<Orders> OrderList
    {
        get
        {
            return  datacontext.Orders.OrderBy(o=>o.OrderDate);
        }
    }

Can you advise how to expose the data sorted without causing this issue?

도움이 되었습니까?

해결책

You can add .ToArray() or .ToList() call to the end of your LINQ query, for example:

public IEnumerable<Orders> OrderList
    {
        get
        {
            return  datacontext.Orders.OrderBy(o=>o.OrderDate).ToList();
        }
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top