-
Notifications
You must be signed in to change notification settings - Fork 934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetching lazy loaded component causes n + 1 query when querying a subclass abstraction #3289
Comments
@bahusoid any chance you could have a look into this? I've tried myself by cloning the code and downloading the appropriate SDK. I've managed to replicate the issue but having stepped through the code I see in the Loader.cs (at which point the SQL has been generated) it includes the select for the lazy loaded property when querying over Also I'm trying to produce a test case and while I can step over the code and see in the SQL profiler the issue, I can't see how to get a count of the total queries which are executed (even after turning on the statistics). I'd appreciate any help as this is the first time I've dived into the NHibernate code and it's a bit alien to me. It's also worth pointing out that if I use |
Yeah, when I have time (not this month) |
After debugging I noticed the main different is the following line: Returns However, it returns the appropriate metadata when the |
Here's a test case: |
Fixed by #3320 |
I've found that when doing a LINQ query and fetching a component it seems to work fine when querying a class, but if I try to query the interface the class implements then the fetch doesn't appear to work.
For example say I have the following:
Which is mapped like so:
Now if I was to say the following, the database would be hit once:
However if I say the following, the database would be hit for each entity in the result:
Edit: See below for a test case.
The text was updated successfully, but these errors were encountered: