I am writing small app (windows C#) for appointments and would like to apply filter on appointment date (i.e. show only appointments that are in future).
The problem is previous developer has stored dates as text(string) in sqlite db. Should I convert string to datetime or int datat type and store the dates as YYYYMMdd format?
Here is the code that I am trying to get the upcoming appointment:
public Appointment GetUpcomingAppointment(string userLocation)
{
using (var dbConn = new SQLiteConnection(App.DB_PATH))
{
var listOfLocations = new List<string> { userLocation, "Australia" };
Appointment a = dbConn.Table<Appointment>().Where(i => listOfSearchedIds.Contains(i._appointmentLevel)
&& i._appointmentType == "Public" && Convert.ToDateTime(i._appointmentDate) > DateTime.Now)
.OrderByDescending(i => i._appointmentDate).FirstOrDefault();
return a;
}
}
The error I get is following:
An exception of type 'SQLite.SQLiteException' occurred in REAppointments.exe but was not handled in user code
Additional information: no such function: todatetime
Thank you in advance for your time.
Aucun commentaire:
Enregistrer un commentaire