0

In a C# projet I want to .Join(...) a view V with a table T and include subtables of T (because of lazy loading).

My code looks like this:

var query = myContext.myView
    .Join(myContext.myTable.Include(t => t.mySubTable),
        v => new { a = v.myProp },
        t => new { a = t.myProp },
        (v, t) => new { v, t }
    );

I get this error:

System.InvalidOperationException : 'Unable to translate a collection subquery in a projection since either parent or the subquery doesn't project necessary information required to uniquely identify it and correctly generate results on the client side. This can happen when trying to correlate on keyless entity type. This can also happen for some cases of projection before 'Distinct' or some shapes of grouping key in case of 'GroupBy'. These should either contain all key properties of the entity that the operation is applied on, or only contain simple property access expressions.'

It works fine without the .Include(). The error does come from the .Include. But the fact is that I do need this include in my case :)

Is there any way to have it to work?

Svyatoslav Danyliv
  • 21,911
  • 3
  • 16
  • 32
A.D.
  • 1,062
  • 1
  • 13
  • 37

0 Answers0