Date range falling between two dates in a LINQ query

后端 未结 2 970
灰色年华
灰色年华 2020-12-17 03:39

I\'m trying to write a select query which returns records where the input date range falls between two date fields in a LINQ query.

My inputs are:

  • date
2条回答
  •  我在风中等你
    2020-12-17 04:23

    It looks backwards to me.

    if the following is true:

    Date1 = start

    Date2 = end

    then i would think startdate after or equal to appointmentstart and enddate before or equal to appointmentend or:

    return (from t1 in db.Appointments where (date1 >= t1.AppointmentStart && date2 <= t1.AppointmentEnd))
    

    i also changed the parens because they didn't make sense to me (seemed like one was missing)

提交回复
热议问题