实体框架4 - 按外国实体排序

时间:2010-09-24 23:21:21

标签: wpf entity-framework sorting collectionviewsource

我得到了

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

当我使用以下CollectionViewSource时:

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

DataContext是ObservableCollection<Course>。我使用的是Entity Framework 4,CourseSessions是Course的一个属性:

public ObjectSet<CourseSession> CourseSessions

在这种情况下如何指定排序,而不是对数据库中的数据进行排序?

1 个答案:

答案 0 :(得分:0)

我认为问题是ObjectSet不支持排序。请看看Nicholas Romanidis撰写的这篇文章: Using a CollectionViewSource to display Master-Detail sorted EntityCollections