0

以下のクエリで結果が返されません。私はtraineeEventテーブルに参加しようとしている方法に関係していると思います.linqクエリには2つのfromコマンドがあります。

私はそれが tranineeEvent Date に関係していることに気付きましたが、もちろんこれはレコードを上書きするため、何も返しません

新しい編集 11:30 私は今、cpdpoints と trainnieevent が 1 つの行に入る必要があることを再確認しました。つまり、select に 2 つの diff 列がないようにします

  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