2
當我試圖使用Linq to Entities查詢Databae上下文時,我得到此異常。
LINQ to Entities不能識別方法'Int32 Int32(System.String)'方法,並且此方法不能轉換爲存儲表達式。LINQ to Entities無法識別MVC中的方法'Int32 Int32(System.String)'方法c#
請幫忙。 在前提前感謝
if (Request.Form["Enroll"] != null)
{
string[] selected = Request.Form["Enroll"].Split(',');
if (selected != null)
{
if (selected.Count() != 0)
{
int k = 0;
foreach (var item in selected)
{
var id = db.EnrollTrainee.Where(i => i.TraineeID == Convert.ToInt32(item[k].ToString())
&& i.TrainerID == Convert.ToInt32(Session["user"].ToString()));
if (id != null)
{
foreach (var a in id)//Getting Exception Here
{
enroll.id = a.id;
db.EnrollTrainee.Remove(enroll);
db.SaveChanges();
}
}
k++;
}
}
}
感謝man..Life保護... – RL89
沒問題,我前幾天有同樣的問題;)高興能幫上忙。 –