开发者

"Only primitive types are supported in this context"

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?


I believe that the problem is Query. The exception says that you cannot pass EnumerableQuery to Linq-to-entities. If Query is IEnumerable try to rewrite first query as:

IQueryable<TBL_Gharardad> Gharardadha =
    from record in dal.TBL_Gharardad
    where Query.Contains(record.PK_Shenase)
    select record;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜