I want to convert the string value to date time
Class
public class demoDate
{
public DateTime DueDate;
public int OrderReportID;
public DateTime _DueDate
{
get { return DueDate; }
set { DueDate = value; }
}
public int _OrderReportID
{
get { return OrderReportID; }
set { OrderReportID = value;}
}
}
Query
var DateQuery = (from o in db.Order_Reports
select new demoDate {
DueDate = System.DateTime.Parse(o.ReportDueDateTime),
OrderReportID = o.OrderReportID
}).ToList();
This coding shows following error
LINQ to Entities does not recognize the method 'System.DateTime Parse(System.String)' method, and this method cannot be translated into a store expression.
Convert.ToDateTime
insteaddb.Order_Reports
(e.g..ToList()
) before doing the projection, as EF can't parse the convert into a sql expression._
instead of the fields?