I have a large query built dynamically with the usage of nested .Where()
. I am using Any()
but after poor performance and some SQL profiling, I found Any() actually causes many round trips and selects each record of a related table for evaluation instead of using a JOIN, for example, which would be much better.
Here's a representation of the tables and what's being done, assuming tables A, B and C:
A <-- B --> C
Suppose I'm querying A and have something like .Where(a => a.B.C.Any(c => c.IsActive))
Is there a better option in spite of using Any()
?