The query contains references to items defined on a different data context

Viewed 10614

I have 2 var from same DBs, after union:

var projectedP1 = P1.Select(x => new Project_test { 
                                     ID_inString = x.ID.ToString(), 
                                     col1 = x.col1, 
                                     col2 = x.col2, 
                                     col3 = x.col3 });
var union = projectedP1.Union(P2);

when P1 alone or P2 alone, everything is fine But when 2 is union, i get this in run-time:

The query contains references to items defined on a different data context.

I tried this similar post, but dun understand. ANyone has any idea?

The specified LINQ expression contains references to queries that are associated with different contexts

1 Answers
Related