【发布时间】:2013-02-15 15:56:40
【问题描述】:
我是 linq 新手,我需要一定的加入。所以我有两个表用于我想加入 Linq 的某些页面,类似于
UserFavorites 表:
Page.id
userClickCount
页面表:
id
everyoneClickCount
用户收藏是在点击或收藏时创建的,因此只有一定数量的链接。我想显示两个表的所有结果,按用户点击次数最多的排序,然后是每个人点击次数最多的排序。
我现在有这个,但它按每个人的数量排序。
pages = (from page in context.Page
join ps in
(from favs in context.UserFavorites
select favs) on page.Id equals ps.Page.Id into temp
from t in temp.DefaultIfEmpty()
orderby t.userClickCount descending, t.Page.everyoneClickCount descending, t.Page.PageName ascending
select dash).ToList();
我只是不知道从这里去哪里。
【问题讨论】:
-
您没有在任何地方过滤当前用户...
-
页面是否有导航属性
UserFavorites?而且,这是 linq to sql 吗?