愚蠢的错误。事实证明Inbound_Results_Id不是我的申请者类的属性。我的申请人类有一个名为InboundResult的复杂对象的属性,它又具有一个名为Inbound_Results_Id的属性。所以我需要做的就是为我的 HQL 做这件事:
string hql = "select a from Applicant a where a.Inbound_Result.Inbound_Results_Id = :inboundResult and a.Harvest_Result_Processed = 0 and a.Applicant_Id not in (" + applicantIdList + ") and a.Status in ('Generated','Received')";
这是完整的代码:
string hql = "select a from Applicant a where a.Inbound_Result.Inbound_Results_Id = :inboundResult and a.Harvest_Result_Processed = 0 and a.Applicant_Id not in (" + applicantIdList + ") and a.Status in ('Generated','Received')";
IList<Applicant> unmatchedApplicants = new List<Applicant>();
try
{
unmatchedApplicants = _ws.Session.CreateQuery(hql)
.SetParameter("inboundResult", indata.Inbound_Results_Id.ToString())
.List<Applicant>();
}
catch (NullReferenceException)
{
Logger.LogMsg("No applicant data was found when looking for unmatched applicants.");
}
这是我的申请人课程:
public class Applicant : Person
{
public virtual long? Applicant_Id { get; protected set; }
public virtual string Status { get; set; }
public virtual Account App_Account { get; set; }
public virtual string Carrier_Name { get; set; }
public virtual InboundResult Inbound_Result { get; set; }
//Applicant Demographics
public virtual string Middle_Name { get; set; }
public virtual string Gender { get; set; }
public virtual DateTime? DOB { get; set; }
}
这是我的 InboundResult 类:
public class InboundResult
{
public virtual long? Inbound_Results_Id { get; protected set; }
public virtual string File_Name { get; set; }
public virtual string Status { get; set; }
public virtual string Header_Line { get; set; }
public virtual string Contents { get; set; }
public virtual string Support_Notes { get; set; }
public virtual DateTime Create_DateTime { get; set; }
public virtual DateTime Update_DateTime { get; set; }
public virtual string User_Name { get; set; }
}