我有以下類中定義無法識別的方法調用時只有日期部分需要
public class IRM_TEMP_Appointment_archive
{
public virtual String VisitNumber { get; set; }
public virtual String WardCode { get; set; }
public virtual String ClinicCode { get; set; }
public virtual String DoctorCode { get; set; }
public virtual String AppointmentStatusCode { get; set; }
public virtual String PatientNumber { get; set; }
public virtual String EpisodeNumber { get; set; }
public virtual String ConsultantCode { get; set; }
public virtual String ReferrerCode { get; set; }
public virtual String MainSpecialtyCode { get; set; }
public virtual String MessageType { get; set; }
public virtual String EpisodeStatusCode { get; set; }
public virtual String ParentEpisodeType { get; set; }
public virtual String AdmissionType { get; set; }
public virtual String AdmitReason { get; set; }
public virtual String BuildingCode { get; set; }
public virtual String BedNumber { get; set; }
public virtual String CategoryCode { get; set; }
public virtual String ConsultantName { get; set; }
public virtual String DischargeDestination { get; set; }
public virtual String DischargeMethod { get; set; }
public virtual String FacilityCode { get; set; }
public virtual String ReferralReason { get; set; }
public virtual String ReferrerAssigningAuthority { get; set; }
public virtual String ReferrerName { get; set; }
public virtual String currentStatus { get; set; }
public virtual String AppointmentTypeText { get; set; }
public virtual String TCILocation { get; set; }
public virtual Boolean analysed { get; set; }
public virtual DateTime AdmitDateTime { get; set; }
public virtual DateTime StopDateTime { get; set; }
public virtual DateTime ScheduledDateTime { get; set; }
public virtual DateTime AppointmentDateTime { get; set; }
public virtual DateTime DischargeDateTime { get; set; }
public virtual DateTime timeOfInsert { get; set; }
public virtual DateTime timeOfAnalyse { get; set; }
public virtual DateTime TCIDate { get; set; }
public virtual int TempAppointmentKey { get; set; }
我需要找到任何預約的患者,對一個給定的日期,爲了這個,我只是需要提取物日期
using (ISessionFactory factory = CreateSessionFactory())
{
using (var session = factory.OpenSession())
{
var query = session.QueryOver<IRM_TEMP_Appointment_archive>()
.Where(a => (a.PatientNumber == MRN) && (a.AppointmentDateTime.ToShortDateString() == DateOfAppointment.ToShortDateString()))
.List()
.ToList<IRM_TEMP_Appointment_archive>();
if (query != null)
{
results = query;
}
}
}
然而,當這個代碼執行,我得到一個錯誤的epression a.AppointmentDateTim
無法識別的方法調用e.ToShortDateString()
我認爲這是因爲它無法確定ToShortDateString的SQL - 所以我該如何編碼這個要求。數據庫是SQL Server。
謝謝。我最終受騙 - 它不會贏得任何獎勵,但效果確實很好。我會把結果放在答案中,而不是把它壓在這裏。 –