-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Where clause on optional navigation causes client-side evaluation #6460
Comments
@smitpatel we believe this is a dupe. Can you please find the other bug? |
@Ettery - Can you post SQL generated for 2nd case, without using |
@smitpatel - apologies for the slow response. When I remove the I have now added a where clause to this query and am seeing similar discrepancies between the generated SQL with and without the reference to the child entity (Currency). Added (classCodes is a string[]):
Resulting SQL with no reference to t.Instrument.Currency.Code has an additional filter:
Resulting SQL when referencing to t.Instrument.Currency the SQL is unchanged. However, EF logs an additional SQL call and appears to be applying the filter in-memory (obviously not going to be as efficient). This is what is logged for the additional call:
I see these lines in the debug which are not there when I don't reference currency:
|
dupe of #4588 |
Steps to reproduce
Looking at this...
The issue
I have 3 related tables: Transaction, Instrument and Currency.
Transaction.InstrumentID -> FK -> Instrument,ID
Instrument.CurrencyID -> FK -> Currency.ID
I want a DISTINCT list of instruments which have one or more transactions, with some instrument detail.
This code:
Produces this SQL, (which is fine except for the unnecessary second join to Instrument):
BUT when I add a reference to retrieve the currency code:
the SQL generated does not have the DISTINCT keyword (major problem - returns 20x too many records) and retrieves all fields on all tables (which I only see when looking at the SQL). Also adds an ORDER BY for some reason.
Further technical details
EF Core version: 1.0.0
Operating system: Win 7 Pro
Visual Studio version: 2015 Update 3
The text was updated successfully, but these errors were encountered: