0

我下面的查询没有返回任何结果。我认为这与我尝试加入 traineeEvent 表的方式有关,一个 linq 查询可以有两个 from 命令。

我意识到这与 tranineeEvent 日期有关,但这当然会覆盖记录,因此什么也不返回

新编辑 11:30 我现在需要 cpdpoints 和 trainnieevent 进入一行,即在 select new 中没有两个差异列这怎么可能

  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) && (startDate >= cpd.StartDate && endDate <= cpd.EndDate) &&
                            (traineeEvent.EmployeeId == id)
                            && traineeEvent.StartDate >= startDate
                            && traineeEvent.EndDate <= endDate
                            && (traineeEvent.TraineeStatus == 1 || traineeEvent.TraineeStatus == 2)
                            && (tEventPart.CPDHours > 0 || tEventPart.CPDPoints > 0)
                            && (cpd.CPDHours > 0 || cpd.CPDPoints > 0)
                      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

                        };

副班是

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace DataObjectLibrary.Reports
    {

            public class EmployeeCPDReportRecord
            {
                public EmployeeCPDReportRecord(

                    string employeeName,
                    DateTime startDate,
                    DateTime endDate,
                    decimal cpdHours,
                    decimal cpdPoints,
                    string eventDesc,
                    DateTime trainingstartDate,
                    DateTime trainingEndDate,
                    decimal trainingcpdHours,
                    decimal trainingCpdPoints,
                    string trainingEventDesc,
                    string cpdtype
                    )
                {
                    EmployeeName = employeeName;       
                    StartDate = startDate;
                    EndDate = endDate;
                    CPDHours = cpdHours;
                    CPDPoints = cpdPoints;
                    EventDescription = eventDesc;
                    CpdType = cpdtype;
                    TrainingStartDate = trainingstartDate;
                    TrainingEndDate = trainingEndDate;
                    TrainingCPDHours = trainingCpdPoints;
                    TrainingCPDPoints = trainingCpdPoints;
                    TrainingEventDescription = trainingEventDesc;


                }

                  public DateTime StartDate { get; set; }
                public DateTime EndDate { get; set; }
                public decimal CPDHours { get; set; }
                public decimal CPDPoints { get; set; }
                public string EventDescription { get; set; }
                public string EmployeeName { get; set; }

                public DateTime TrainingStartDate { get; set; }
                public DateTime TrainingEndDate { get; set; }
                public decimal TrainingCPDHours { get; set; }
                public decimal TrainingCPDPoints { get; set; }
                public string TrainingEventDescription { get; set; }
                public string TrainingEmployeeName { get; set; }
                public string CpdType { get; set; }
        }
    }
4

0 回答 0