I am trying to add datetime to a Linq query.
Error: LINQ to Entities does not recognize the Method Method.DateTime AddMinutes (Double) 'method, and this method cannot be translated into a storage expression.
It works in Link to SQL, but does not work with LINQ to Entity.
Is there any other way to do this.
thank
DataClassesDataContext datacontext = new DataClassesDataContext();
int concertid = Convert.ToInt32(ddlConcerts.SelectedValue.ToString());
GridView1.DataSource = (from ticketallocation in datacontext.tblConcertTicketAllocation
where ticketallocation.ConcertID == concertid
&& ticketallocation.Section == ddlSection.SelectedValue
&& ticketallocation.Row == ddlRows.SelectedValue
select new
{
AutoID = ticketallocation.AutoID,
ConcertID = ticketallocation.ConcertID,
Section = ticketallocation.Section,
Row = ticketallocation.Row,
Seats = ticketallocation.Seats,
Status = ticketallocation.Status == 3 ? "<span style=\"color:#FF0000;\">Sold</span>" :
ticketallocation.Status == 2 ? "<span style=\"color:#999999;\">Aisle Break</span>" :
ticketallocation.Status == 0 ? "<span style=\"color:#009900;\">Available</span>" :
ticketallocation.Status == 1 && ticketallocation.DateandTime.Value.AddMinutes(16) > DateTime.Now ? "<span style=\"color:#FF9900;\">Looking</span>" : "<span style=\"color:#009900;\">Available</span>",
DateandTime = ticketallocation.DateandTime,
OrderNumber = ticketallocation.OrderNumber
}).ToList();
GridView1.DataBind();
source
share