Help with linq query, problem with skip and take when joining on multiple queries -


I want to give a bunch of notifications on my home screen, though I am using paging to make sure I do not do concat 2, there are 3 or 4+ questions in memory which can get thousands of results. I am having trouble writing this question, any guidance would be appreciated ...

Domain model: I have a bunch of reports, you can create reports, create jobs and work Can comment on all the reports related to.

My query needs to be sent out:

  1. All new reports (based on the date they were created) < < Li> All reports are closed (based on the date of closure)
  2. All new tasks have been made on this report (Task Manager monitors some)
  3. All the latest comments On the job

    My code is up to now:

      [non-action] Private IELIT & lt; Notification DTO & gt; GetNotifications (logononer dtio logonuser, int vagu, int le) {var allreports = _repo.All & lt; Report & gt; (); Alltasks = _repo.All & lt; ReportTask & gt; () Join (allreports, x => x.reportID, y = & gt; y.ReportID, (_task, _report) => new {_report, _task}). .Where (X => x._task.CompanyID == Logonuser.company ID || x._desk.assassetcompanyID == logonunuser.companyID); Var _companies = _repo.All & lt; Company & gt; (); Var _users = _repo.All & lt; Users & gt; (); Var _activities = alltasks.OrderByDescending (o = & gt; o._task.DateCreated) .Select (x = & gt; New NotifcationDTO {title = x._report.SubjectPropertyAddress1, MessageId = x._report.ReportID, NotificationType = NotificationType.NewTask .ToString (), comment = x._task.Title, value = Importance.Medium.ToString (), timestamp = x._task.DateCreated, UserFriendlyName = _users.Where (y = & gt; y.UserID == x._task KUserID). Frstor default (). login, EntityFriendlyName = _companies.Where (y = & gt; y.CompanyID == x._task.CompanyID) .FirstOrDefault (). identifier}); Return _activities.Skip (left). Take (take) .Olist ();   

    // query to update- ...

      var comment = _repo.All & lt; InstructionTaskComment & gt; (); Var _taskcomments = alltasks .Join (note, X = & gt; x._task.TaskID, Y = & gt; y.TaskID, (_task, _comment) = & gt; new {_task, _comment}) .OrderByDescending (O = & gt; o ._comment.Timestamp) .Select (x = & gt; new NotifcationDTO {title = x._task._report.SubjectPropertyAddress1, MessageId = x._task._report.ReportID, NotificationType = NotificationType.Comment.ToString (), comment = x._comment .Comment, value = Importance.Low.ToString (), timestamp = x._comment.Timestamp, UserFriendlyName = _users.Where. (y = & gt; y.UserID == x._comment.UserID). FirstOrDefault () Login, EntityFriendlyName = _companies.Where (y = & gt; y.CompanyID == x._comment.CompanyID) .FirstOrDefault (.) Identifier}); Unless you are working with all the  IQuerable    

    they tamper with SQL And will not be included in "Memory Consumption". You can use a tool to generate related SQL.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -