我的代码的最后一行有这个例外:
无法创建类型为'System.Linq.EnumerableQuery`1'的常量值。在此上下文中仅支持原始类型(例如Int32,String和Guid')。
我的代码:
using (GharardadhaEntities dal = new GharardadhaEntities())
{
IQueryable<TBL_Gharardad> Gharardadha =
from record in dal.TBL_Gharardad
join shenase in Query on record.PK_Shenase equals shenase
select record;
var q = (from record in dal.TBL_MabalegheDariaftieMahane
where record.TBL_Gharardad == Gharardadha.First()
select record);
ulong v = (ulong)Gharardadha.First().MablagheDariaftiKol;// I have got the error on this statement
}
我的代码出了什么问题?
答案 0 :(得分:3)
我认为问题是Query
。例外情况表示您无法将EnumerableQuery
传递给Linq-to-entities。如果Query
为IEnumerable
,请尝试将第一个查询重写为:
IQueryable<TBL_Gharardad> Gharardadha =
from record in dal.TBL_Gharardad
where Query.Contains(record.PK_Shenase)
select record;