soccerway
soccerway

Reputation: 11961

SQLite.SQLiteException: no such function: tostring using LINQ query while getting CurrentDate

I would like to get two columns like SoccerStatus, SoccerDate from the SoccerAvailability in SQLite database into a list where SoccerDate="Today" using LINQ query ? I have tried the below query, but its throws exception, I need CurrentDate alone, no time is needed in my query.

List<SoccerAvailability> myList = (from x in conn.Table<SoccerAvailability>().Where(x => x.CurrentDate == DateTime.Now.ToString("ddMMyyyy")) select x).ToList();

Unhandled Exception:

SQLite.SQLiteException: no such function: tostring

Upvotes: 1

Views: 643

Answers (1)

Jason
Jason

Reputation: 89102

convert the current date to a string before you execute your query

var currentDate = DateTime.Now.ToString("ddMMyyyy");
List<SoccerAvailability> myList = (from x in conn.Table<SoccerAvailability>().Where(x => x.CurrentDate ==  currentDate) select x).ToList();

Upvotes: 3

Related Questions