Assume I have 2 entities: Ent
and SubEnt
with N:1 relationship. So, there are navigation properties SubEnt.Ents
and Ent.SubEnt
. Also, I have some ObjectQuery defined:
ObjectQuery<SubEnt> se;
How can I create ESQL query that selects all entities from Ent
that have Ent.SubEnt
from se
?
Something like that:
SELECT VALUE it FROM Ent WHERE Ent.SubEnt IN @p
Where @p == se. It looks like a nested query. But this syntax is not correct because "Only scalar types are supported".
Once you have ObjectQuery you cannot pass it back to ESQL. So you must either write the whole query in ESQL without separates se
or you must work on with ObjectQuery itself. In later case try something like:
var query = from e in context.Ents
join s in se on e.Ent.Id equals s.Id
select e;
Unless you example is just some simplification of bigger query you can also simply try:
var query = se.SelectMany(s => s.Ents).Distinct();