SQLite实体框架查询返回下一个可用日期

时间:2016-08-15 14:18:44

标签: entity-framework sqlite linq-to-sql

我有这个查询,从约会表我想得到该客户的下一个日期。

 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;

当客户报名时,他们将有时间与导师一起上课,而在主页上,我想显示下一个可用的预约

- 更新 -

这就是我写的。这会影响性能还是应该没问题?我仍然发现如何从预约表中获得前1名

   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});

0 个答案:

没有答案