Search code examples
entity-frameworkentity-framework-4

Can we do cross join in EF?


So basically I asked this question while back:

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

But this time I am doing it in EF. Does EF supports cross joining between two tables?


Solution

  • You can't do joins between different data context's. You would have to do the join with linq-objects

    var crossJoin = from a in context.TableA.AsEnumerable()
                    from b in context2.TableB.AsEnumerable()
                    select new
                    {
                      a,
                      b
                    };