I want to using lambda expression to compare current DateTime.Now with time retrieved from database (time).
I try this:
string time = DateTime.Now.Hour.ToString("00") + DateTime.Now.Minute.ToString("00") + DateTime.Now.Second.ToString("00");
TimeSpan _currentTime = TimeSpan.ParseExact(time, "HHmmss", CultureInfo.InvariantCulture);
IQueryable<user> Query = _context.user.Where(s => s.userShifts.Any(s2 => s2.DayOfWeekId == _todayNumber && _currentTime >= s2.TimeFrom && _currentTime <= s2.TimeTo));
I got the following error:
{"Input string was not in a correct format."}
What's the wrong !!