0
我想抛出我的主屏幕上一堆通知,但是我使用分页,以确保我不concage 2,3或4+查询内存可能有成千上万的结果。我有一点麻烦写这个查询,任何指导,将不胜感激......LINQ查询帮助,跳过问题,并加入多个查询
域模型:我有一大堆的报告,您可以创建/关闭报告,创建任务,并在其上所有的任务发表评论与报告有关。
我的查询需要发送:
- 创建的所有新报表(根据创建日期)
- 所有报表关闭(基于封闭日期)所有新上的这个创建的任务报告(任务管理器帮助跟踪事情发生)
- 对任务的所有最新评论
我迄今为止代码:
[NonAction]
private IList<NotifcationDTO> GetNotifications(LoggedonuserDTO loggedonuser, int skip, int take)
{
var allreports = _repo.All<Report>();
var alltasks = _repo.All<ReportTask>().Join(allreports ,
x => x.ReportID, y => y.ReportID, (_task, _report) =>
new
{
_report,
_task
})
.Where(x => x._task.CompanyID == loggedonuser.CompanyID || x._task.AssignedToCompanyID == loggedonuser.CompanyID);
var _companies = _repo.All<Company>();
var _users = _repo.All<User>();
var _activities = alltasks.OrderByDescending(o => o._task.DateCreated)
.Select(x => new NotifcationDTO
{
Title = x._report.SubjectPropertyAddress1,
MessageID = x._report.ReportID,
NotificationType = NotificationType.NewTask.ToString(),
Comment = x._task.Title,
Importance = Importance.Medium.ToString(),
Timestamp = x._task.DateCreated,
UserFriendlyName = _users.Where(y => y.UserID == x._task.UserID).FirstOrDefault().Login,
EntityFriendlyName = _companies.Where(y => y.CompanyID == x._task.CompanyID).FirstOrDefault().Identifier
});
return _activities.Skip(skip).Take(take).ToList();
//更新 - 查询Concat的到...
你的代码有什么问题? – Magnus
你在寻求帮助,写下查询?你在哪里遇到麻烦? – msarchet
我已经加入上面的第二个查询,基本上我想Concat的两个查询牢记分页,我不想在内存CONCAT ...... – Haroon