0
投射完成時獲取運行時錯誤。它如何解決?運行時錯誤無法投射對象
public spc GetSc(int ID)
{
var SC = from items in db.Stable where items.id== ID orderby items.id select items;
SC.Cast<spc>();
return (spc)SC; // This line throws the error
}
錯誤消息:
Unable to cast object of type
'System.Data.Entity.Infrastructure.DbQuery`1[Tool.Models.Transaction.spc]'
to type 'Tool.Models.Transaction.spc'.