0
這是我的代碼如何在LINQ使用變量值實體
if (Count < LeaveTypeCount)
{
for (int i = 0; i < LeaveTypeCount; i++)
{
var LeaveId = from l in CompObj.LeaveTypes
select l.LeaveID;
var leaveIdArray = LeaveId.ToArray();
var LeaveDefault = (from c in CompObj.LeaveTypes
where (c.LeaveID ==leaveIdArray[i])
select new { c.DefaultLeave }).FirstOrDefault();
Int32 DefaultCount = Convert.ToInt32(LeaveDefault.DefaultLeave);
AssignedLeave AddObj = new AssignedLeave();
AddObj.EmpID = EmpID;
AddObj.AssignedYear = LeaveYear;
AddObj.LeaveID =leaveIdArray[i];
AddObj.TotalLeave = DefaultCount;
CompObj.AssignedLeaves.AddObject(AddObj);
CompObj.SaveChanges();
}
}
但其示出了錯誤的LINQ表達式節點類型「ArrayIndex」在LINQ不支持對實體。
我該如何解決這個問題,或者有什麼其他的方式做這個任務
感謝
非常感謝您的幫助 – user2516261