1
我有一個函數返回一個JsonResult,它應該是與所提供的guid關聯的所有對象類型的列表。但我得到錯誤linq返回關聯的對象類型
LINQ to Entities不識別方法'System.Type GetType()'方法,並且此方法不能轉換爲存儲表達式。
這可能嗎?
public JsonResult GetWebObjectTypesByWebObject(Guid id)
{
JsonResult result = new JsonResult();
var resultData = (from w in db.WebObjects
from r in w.RelatedWebObjects
where w.Id == id
select new { Type = r.GetType().BaseType.Name });
result.Data = resultData;
result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
return result;
}
可能是另一個'ToList'掛斷 - 可能試着強迫你的結果進入列表。 –
同意,ToList然後選擇。 – maxbeaudoin
仍然會出現相同的錯誤。啊,我明白了,tolist然後選擇。讓我嘗試一下。 – bflemi3