I have written this code for a date range filter in c# using linq but am getting an error on the server. On my local machine, the code is working very well but when deployed on the server it is getting an error.
This is my code:
string fromDate = "15-03-2017";
string toDate = "17-03-2017";
DateTime FromDate = Convert.ToDateTime(fromDate);
DateTime ToDate = Convert.ToDateTime(toDate);
UserList = db.Users
.Where(t => DbFunctions.TruncateTime(t.datetime) >= FromDate
&& DbFunctions.TruncateTime(t.datetime) <= ToDate)
.OrderByDescending(a => a.datetime)
.ToList();
I don't know where my mistake is in this query. If anyone knows then please let me know how to resolve this issue. On my local machine the code is working very well but on server it is getting an error.
linqtag.