Note that there are some explanatory texts on larger screens.

plurals
  1. POlinq combine results from two tables to one select new statment?
    text
    copied!<p>With the following query how to I change that I dont have two sets of fields in the select new I want the information going into one set of columns not having two and a type field to say if its a traineeevent or a cpd event ?</p> <pre><code> List&lt;EmployeeCPDReportRecord&gt; employeeCPDRecords = new List&lt;EmployeeCPDReportRecord&gt;(); string employeeName; var q = from cpd in pamsEntities.EmployeeCPDs from traineeEvent in pamsEntities.TrainingEventTrainees join Employee e in pamsEntities.Employees on cpd.EmployeeID equals e.emp_no join TrainingEventPart tEventPart in pamsEntities.TrainingEventParts on traineeEvent.TrainingEventPartId equals tEventPart.RecordId where (cpd.EmployeeID == id) &amp;&amp; (startDate &gt;= cpd.StartDate &amp;&amp; endDate &lt;= cpd.EndDate) &amp;&amp; (traineeEvent.EmployeeId == id) &amp;&amp; (traineeEvent.TraineeStatus == 1 || traineeEvent.TraineeStatus == 2) &amp;&amp; (tEventPart.CPDHours &gt; 0 || tEventPart.CPDPoints &gt; 0) &amp;&amp; (cpd.CPDHours &gt; 0 || cpd.CPDPoints &gt; 0) || traineeEvent.StartDate &gt;= startDate || traineeEvent.EndDate &lt;= endDate orderby cpd.StartDate select new { surname = e.surname, forname1 = e.forename1, forname2 = e.forename2, EmployeeID = cpd.EmployeeID, StartDate = cpd.StartDate, EndDate = cpd.EndDate, CPDHours = cpd.CPDHours, CPDPoints = cpd.CPDPoints, Description = cpd.Description, TrainingStartDate = tEventPart.StartDate, TrainingEndDate = tEventPart.EndDate, TrainingCPDHours = tEventPart.CPDHours, TrainingCPDPoints = tEventPart.CPDPoints, TrainingEventDescription = tEventPart.Description }; if (q != null) { Array.ForEach(q.ToArray(), i =&gt; { if (ContextBase.encryptionEnabled) employeeName = ContextBase.Decrypt(i.surname) + ", " + ContextBase.Decrypt(i.forname1) + " " + ContextBase.Decrypt(i.forname2); else employeeName = i.surname + ", " + i.forname1 + " " + i.forname2; if (i.TrainingStartDate != new DateTime(1900, 1, 1)) employeeCPDRecords.Add(new EmployeeCPDReportRecord(employeeName, Convert.ToDateTime(i.StartDate), Convert.ToDateTime(i.EndDate), Convert.ToDecimal(i.CPDHours), Convert.ToDecimal(i.CPDPoints), i.Description,i.t,i.EndDate,Convert.ToDecimal(i.CPDHours),Convert.ToDecimal(i.CPDPoints),i.Description,"L&amp;D")); else employeeCPDRecords.Add(new EmployeeCPDReportRecord(employeeName, Convert.ToDateTime(i.StartDate), Convert.ToDateTime(i.EndDate), Convert.ToDecimal(i.CPDHours), Convert.ToDecimal(i.CPDPoints), i.Description, i.StartDate, i.EndDate, Convert.ToDecimal(i.CPDHours), Convert.ToDecimal(i.CPDPoints), i.Description, "Employee CPD")); }); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload