【发布时间】:2014-11-29 20:29:41
【问题描述】:
我希望我的搜索从数据库中返回随机条目。如何执行此操作?
这是我的搜索功能,我正在使用加入查询并采用新模型来传递属性。
var planetfeedsOrder = from a in db.PlanetFeeds
where a.PlanetFeedOwnerId == id || a.PlanetFeedPosterId == id
&& a.CurrentState != 1
join c in db.Graphs on a.PlanetFeedItemGraphId equals c.GraphID
join u in db.UserInfos on a.PlanetFeedOwnerId equals u.UserInfoID
orderby a.PostDate descending
select new UserInfoViewModel
{
AvatarURL = u.AvatarURL,
UserName=u.FirstName +" "+u.LastName,
GraphItemDescription = c.GraphItemDescription,
GraphItemURL = c.GraphItemURL,
isRootFeed = a.isRootFeed,
PostDate = a.PostDate,
CurrentState = a.CurrentState,
};
return PartialView("_PlanetfeedPartial",planetfeedsOrder.Take(itemCount).ToList());
【问题讨论】:
标签: linq asp.net-mvc-4