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