Skip to content
Advertisement

LINQ double INNER JOIN on query translation when using selectMany

I have the following LINQ statement:

Which uses the repository pattern. The search function is the one below:

When I inspect the command that arrives in SQL Server I see that the query is translated in the following SQL:

It works perfectly, but why there is an inner join duplicated:

is a non-sense to me!

If I remove it from the SQL it works as before. Is there any issue in my LINQ query that causes this strange SQL?

here is the definition of the entities:

and here the definition of the relationships with fluent API:

Advertisement

Answer

Rewrite query via LINQ Query syntax and you can simplify your query with ease. The following query do not create non wanted joins:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement