2
Answers

Getting error in LINQ

LINQ to Entities does not recognize the method 'System.DateTime ToDateTime(System.String)' method, and this method cannot be translated into a store expression.
 
IN This Line :-
 
Events = db.Events.Where(a => (a.Active == true) && (a.IsDelete == false && a.IsRejected == false && Convert.ToDateTime(a.EventEndDate) > DateTime.Now)).ToList(); 
Answers (2)
0
Midhun T P

Midhun T P

NA 19.7k 281.1k 8y
Hi,
 
Please try like below - 

Events = db.Events.Where(a => (a.Active == true) && (a.IsDelete == false && a.IsRejected == false && SqlFunctions.DateDiff("s",a.EventEndDate, DateTime.Now) > 0)).ToList();
Accepted
0
Dr.Ajay Kashyap

Dr.Ajay Kashyap

NA 455 31k 8y

Midhu T P Sir.... thank you so much