Repository navigation
Conversation
|
Hi @tuespetre, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! The agreement was validated by .NET Foundation and real humans are currently evaluating your PR. TTYL, DNFBOT; |
3b25bb1 to
6dea783
Compare
|
Poaching this @maumar |
|
The changed test SQL is an improvement here, those tests should be using parameter injection but instead they are not because of bug here Instead of trying to find SelectExpression by asking QueriesBySource, it should use Ideally, a querymodelvisitor (qmv) should store only SelectExpression(s), which are required to be run to generate results of query model being visited. There can be more than one SelectExpression stored it they are being stitched together. That is the reason when we lift the join clause into main select expression we remove the entry for join clause in QueriesBySource. If a query source is being lifted then there should be no need to store it in QueriesBySource, instead SelectExpression.HandlesQuerySource method should tell if particular qs is part of SelectExpression. This change brought test SQL changes because of existing bug. Instead the underlying bug should be fixed. Leaving that aside, this does not add any value rather increases the metadata size. |
smitpatel
left a comment
There was a problem hiding this comment.
Correct approach would be to fix bug in BindPropertyToOuterParameter
WOW! 😱 Big 'duh' moment for me, now I am seeing all of the places where a query source is not being mapped to an added join expression or subquery select expression, and how I was using these changes to compensate for that. |
6dea783 to
e14fbf8
Compare
|
🆙📅 |
|
Merged via 2a8a3b5 |
This PR makes the following changes:
QueriesBySourcea private API toRelationalQueryModelVisitorQueriesanIEnumerable<SelectExpression>instead ofICollection<SelectExpression>AddQuerytoMapQueryto better align with what the method is doingThis is, again, a set of changes I am splitting out from #7543. The idea is that as the query model is being visited, each query source gets mapped to a
SelectExpressionso that during binding (either withinSqlTranslatingExpressionVisitororMemberAccessBindingExpressionVisitoror etc.) there will be optimal opportunity to find or add the appropriate projection expressions.As you can see this change already has benefits outside of the context of #7543 in that it has optimized some types of N+1 queries that would otherwise pull much more data on each of the +1 queries.