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

发布于 2024-09-25 00:47:02 字数 748 浏览 0 评论 0原文

我得到

'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>

: The DataContext is an ObservableCollection。我使用的是 Entity Framework 4,CourseSessions 是 Course 的一个属性:

public ObjectSet<CourseSession> CourseSessions

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

全部不再 2024-10-02 00:47:02

我认为问题在于ObjectSet不支持排序。请看一下 Nicholas Romanidis 的这篇文章:
使用 CollectionViewSource 来显示主从排序的EntityCollections

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文