One application is being converted to EntityFrameWork codefirst. Right now, my code is
string sFrom ="26/12/2013"; select * FROM Trans where CONVERT(datetime, Date, 105) >= CONVERT(datetime,'" + sFrom + "',105)
I also tried.
DateTime dtFrom = Convert.ToDateTime(sFrom ); TransRepository.Entities.Where(x =>Convert.ToDateTime(x.Date) >= dtFrom)
But I encountered this problem.
LINQ to Entities does not recognize the method 'System.DateTime ToDateTime(System.String)' method
kindly assist I appreciate you.
Your date column is a string—why? Why is it not a
In any case, you'll see that problem if you try to execute conversions using.NET methods in a.Where statement against a repository of entities.
Changing that column from a string to a DateTime and continuing from there would be your best course of action. in that case, the
a statement like:
DateTime dtFrom = Convert.ToDateTime(sFrom ); var something = TransRepository.Entities.Where(x => x.Date >= dtFrom) ;