Sql Linq不确定语法是否正确

Sql Linq不确定语法是否正确,sql,linq,Sql,Linq,我下面的查询没有返回任何结果。我认为这与我尝试加入TraineEvent表的方式有关。一个linq查询可以有两个from命令 我意识到这与TranineEvent日期有关,但这个词当然会覆盖记录,因此不会返回任何内容 新编辑11:30我重温现在我需要cpdpoints和trainnieevent进入一行,即在“选择新”中不包含两个差异列这是怎么可能的 var q = from cpd in pamsEntities.EmployeeCPDs fro

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

我意识到这与TranineEvent日期有关,但这个词当然会覆盖记录,因此不会返回任何内容

新编辑11:30我重温现在我需要cpdpoints和trainnieevent进入一行,即在“选择新”中不包含两个差异列这是怎么可能的

  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

                        };

您还可以提供相关的类结构吗please@Simsons我加了那个班now@Simsons我认为这与培训活动日期有关,他们没有此用户的记录,但我尝试了| |或更换了他们的记录,结果混乱了PamEntities.EmployeeCPD返回的是什么?什么是返回(类)类型和结构?@Simsons我知道了,但我不想要的是有两组字段,我只想要一个CPDHours和CPDPoints,这样可以更轻松地报告它,并有一个类型字段来说明它的L&D或EmployeeCPD??因此,公共字符串CpdType{get;set;}
    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; }
        }
    }