"In this environment, only basic types are supported."

c# entity-framework

Question

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?

1
0
5/22/2011 7:45:37 AM

Accepted Answer

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;
3
5/22/2011 7:05:06 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow