SQLite Entity Framework 查询 return 下一个可用日期
SQLite Entity Framework query to return next available date
我有这个查询从约会开始 table 我想获得该客户的下一个日期。
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?"}
Class 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; }
}
Class 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;
当客户注册时,他们将获得与讲师上课的时间,在主页上,我想显示下一个可用预约
--更新--
这是我写的。这会影响性能还是应该没问题?仍然在寻找如何从约会中获得前 1 名 table
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});
得到它与这个一起工作:
var s = (from i in Customer
let p = Appointment.Where(p2 => i.ID == p2.CustId && p2.LessonDate >= DateTime.Now).OrderBy(ta => ta.LessonDate).FirstOrDefault()
select new
{
i, p.LessonDate
});
我有这个查询从约会开始 table 我想获得该客户的下一个日期。
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?"}
Class 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; }
}
Class 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;
当客户注册时,他们将获得与讲师上课的时间,在主页上,我想显示下一个可用预约
--更新--
这是我写的。这会影响性能还是应该没问题?仍然在寻找如何从约会中获得前 1 名 table
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});
得到它与这个一起工作:
var s = (from i in Customer
let p = Appointment.Where(p2 => i.ID == p2.CustId && p2.LessonDate >= DateTime.Now).OrderBy(ta => ta.LessonDate).FirstOrDefault()
select new
{
i, p.LessonDate
});