I am using ASP.NET entity framework and I am trying to create an SqlQuery but I get this error:
The specified cast from a materialized 'System.Int64' type to the 'System.Int32' type is not valid.
My problem is I don't know which column is giving me trouble and how to fix it. Here is my code. I don't think its my casts that I am doing because those are strings.
return View(db.Data.SqlQuery("SELECT ROW_NUMBER() OVER(ORDER BY slotOrder ASC) AS id,
concat(a.dateSlot, ' - ', a.timeSlot) as dateSlot,
concat(a.dateSlot, '-', a.timeSlot) as timeSlot,
COUNT(*) as slotOrder
FROM Appointments a
LEFT OUTER JOIN dateTimeSlots b
ON a.dateSlot = b.dateSlot AND a.timeSlot = b.timeSlot
GROUP BY a.dateSlot, a.timeSlot, b.slotOrder
ORDER BY b.slotOrder").ToList());
Here is my class:
public class dateTimeSlots
{
public int id { get; set; }
[DisplayName("Date")]
public string dateSlot { get; set; }
[DisplayName("Time")]
public string timeSlot { get; set; }
[DisplayName("Order")]
public int slotOrder { get; set; }
}
idorslotOrderare longs and not ints. Probablyid