The same query worked in .Net 3.5 but not in .Net 4.5.2 There are lots of posts here with the same error, and tried almost all but of no use. I have extracted everything into a separate variable for querying. Still i am getting the error -
LINQ to Entities does not recognize the method 'System.String Format(System.String, System.Object)' method, and this method cannot be translated into a store expression.
private void LoadAppointmentData()
{
var user = Session["user"].ToString();
var userFirstName = db.Users.SingleOrDefault(u => u.FirstName == user);
var userFN = userFirstName.username;
var chwWorker = from c in db.PatientContacts
where c.UserName == userFN &&
(c.PCP_Status == "Appointment Made" || c.PCP_Status_AWC == "Appointment Made"
|| c.PCP_Status_AWDV == "Appointment Made" ||
(c.PCP_Status == "RX for Mamogram" && c.Status == "Appointment Made"))
orderby c.PCP_Status_Date descending
select new
{
Id = c.MemberID,
Name = c.PatientFirstName + " " + c.PatientLastName,
PCP_Appt = $"{c.PCP_Status_Date:d}",
Mammogram_Appt = $"{c.StatusDate:d}",
Phone = GetPhone(c.MemberID)
};
if (chwWorker.Any())
{
if (grvAppointmentList != null)
{
pnlAppointmentFollowUp.Visible = true;
grvAppointmentList.DataSource = chwWorker;
grvAppointmentList.DataBind();
}
}
}
I am not sure what else to change to make this query run.