“在此上下文中仅支持原始类型”
我在代码的最后一行遇到了这个异常:
无法创建“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
}
我的代码有什么问题?
I have got this exception in the last line of my code:
Unable to create a constant value of type 'System.Linq.EnumerableQuery`1'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
My Code:
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
}
What is wrong with my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题出在
查询
。该异常表明您无法将EnumerableQuery
传递给 Linq-to-entities。如果Query
是IEnumerable
尝试将第一个查询重写为:I believe that the problem is
Query
. The exception says that you cannot passEnumerableQuery
to Linq-to-entities. IfQuery
isIEnumerable
try to rewrite first query as: