实体框架数据排序

时间:2012-10-17 06:20:19

标签: c# entity-framework

我正在使用实体框架为UserStream(如fb)开发一个项目,我已经成功实现了它,我想要的功能是,如果有人评论状态/帖子那个状态/帖子应该显示在顶部,(比如在FB) 目前最新的帖子显示在顶部,但我无法根据评论进行排序,下面是我的数据库表格结构

tblPosts:                 tblUsers                     tblUserPosts:          tblPostComments
PostId bigint PK          UserId bigint PK             UserPostID bigint PK   CommentID bigint PK
Desc  text                Username  varchar(200)       UserID   bigint FK     PostId bigint FK
Type bingint              Password varchar(100)        PostId   bigint FK     Comment varchar(200)
URL  varchar(200)                                                             Commentedby bigint FK
Privacy varchar(50)                                                           Postedon datetime
Postedon datetime

在我的cs代码上,我正在检索tblUserPosts的List然后在tblPosts Posteddate的基础上对它进行排序,但我没有关于tblPostComments的任何信息,我如何在注释的基础上对记录进行排序

这就是我如何排序记录

List<tblUserPosts> objlst = new List<tblUserPosts>();
//Adding items to objlst
      UserStreamViewModel model = new UserStreamViewModel
                {
//I am not having d.tblPostComments or d.tblPosts.tblComments.PostedOn
                    propResourcesList = objlst.OrderBy(d=>d.tblPosts.PostedOn);

                };

0 个答案:

没有答案