Only primitive types allowed Issue in LINQ to entities RRS feed

  • Question

  • Hi , 

    I am using expression class of LINQ to create a dynamic query based on filter passed . Code snippet looks like 

    // _accountId is the filter of type string

    Expression<Func<BatchOrderReport, bool>> testExpression = t => t.AccountId == _accountId; 

    result = result.Where(so => so.BatchOrderRequest.Any(bor => bor.BatchOrderReport.Any(testExpression )));

    result is of type IQuerable<Batch> and has entity collection property BatchOrderRequest of type EntityCollection . BatchOrderRequest  has one more entity collection BatchOrderReport of type ENtityCollection. 

    I am trying to create a LINQ expression based on the filter account Id . When this LINQ query is executed , system gives an error as 

    "Only primitive types ('such as Int32, String, and Guid') are supported in this context."

    I am not sure why this is happening ? Any help or pointers will be really appreciated. 



    Siddhesh Sawant

    • Moved by CoolDadTx Friday, June 28, 2013 2:20 PM EF related
    Friday, June 28, 2013 1:02 PM