Error Message: “Only primitive types or enumeration types are supported in this context.”

前端 未结 1 1295
执笔经年
执笔经年 2021-01-22 13:42

I\'m working a report for an asp.net page and I\'m trying to assign the results of this linq statement to an existing dataset but I\'m receiving the \"Only primitive types or en

1条回答
  •  清酒与你
    2021-01-22 14:37

    You can't mix entity types from different contexts in single LINQ query. Either put them into single context, or try to execute this:

    var employeeIds = (from o in contextHistory.emp_history select o.employeeID).ToList();
    

    and then pass this list into the second query:

    var rslt = (from c in contextTable.TableofOrganizationRpts
                where !employeeIds.Contains((int)c.employeeid_fk)
                select c).ToList();
    

    This should generate IN condition in resulting SQL query. Note, that this might work slow.

    0 讨论(0)
提交回复
热议问题