0
我有這個查詢從預約表我想要獲得該客戶的下一個日期。SQLite實體框架查詢返回下一個可用日期
from customer in db.Customers
from order in db.Appointment
.Where(o => customer.CustomerId == o.CustomerId)
.DefaultIfEmpty()
Select new {NextAppointment = "How to get this date?"}
類Appointment
:
public class Appointment
{
public long Id { get; set; }
public string AppointmentInstructorName { get; set; }
public DateTime LessonDate { get; set; }
public long CustomerID {get; set;}
public string AppointmentLessonAddress { get; set; }
}
類Customer
:
public string FirstName;
public string LastName;
public string Suburb;
public string NextAppointment;
public string Mobile;
public string DrivingLicenceNo;
public string Name
{
get { return $"{FirstName} {LastName}"; }
}
public int ID;
當客戶簽約,他們將獲得一次針對一個課程的講師,並在家裏頁面,我想顯示下一個可用約會
- 更新 -
這就是我寫的。這會影響性能還是應該好?還是查不到雖然我如何從預約表
var obj = (from a in Appointment
orderby a.LessonDate ascending
where a.LessonDate>= DateTime.Now
select a);
var d = (from c in Customer
join o in obj on c.ID equals o.CustId into ps
from o in ps.DefaultIfEmpty()
select new { c, o.LessonDate});
爲什麼不'Appointment'有一個'DateTime'屬性,而不是日期和時間的字符串?在查詢中這是一件麻煩事! –
這是我第一次玩sqlite,並不確定它會如何表現,但你可以把它當作日期時間(我會改變模型來反映這一點)。 – Baahubali