简体   繁体   中英

Entity Framework 4 - Sorting by foreign entity

I get

'System.Windows.Data.BindingListCollectionView' view does not support sorting

when I use the following CollectionViewSource:

    <CollectionViewSource Source="{Binding Path=CourseSessions}" x:Key="cvsCourses">
        <CollectionViewSource.SortDescriptions>
            <ComponentModel:SortDescription PropertyName="StartDate"/>
        </CollectionViewSource.SortDescriptions>
    </CollectionViewSource>

The DataContext is an ObservableCollection<Course> . I am using Entity Framework 4 and CourseSessions is a property of Course:

public ObjectSet<CourseSession> CourseSessions

How can I specify sorting in this case, short of sorting the data coming out of the database?

I think the problem is that ObjectSet does not support sorting. Please, have a look to this article by Nicholas Romanidis: Using a CollectionViewSource to display Master-Detail sorted EntityCollections

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM