Skip to content

Query: List of refactoring ideas #7520

Closed
Closed

Description

@anpete

Brain dump of potential refactorings in the query pipeline captured from a discussion today with @smitpatel and @maumar.

- [ ] Immutable SelectExpression via facade/visitors Not worth

@smitpatel, @maumar Feel free to add more detail here.

Activity

  1. added this to the 2.0.0 milestone on Feb 1, 2017
  2. self-assigned this
    on Feb 9, 2017
  3. tuespetre commented on Mar 7, 2017

    @tuespetre
    Contributor

    How about the RelationalEntityQueryableExpressionVisitor vs MemberAccessBindingExpressionVisitor thing? Not the fact that they are two separate visitors (they have different purposes) but the fact that RelationalEntityQueryableExpressionVisitor seems to be overstepping its bounds by being responsible for adding things to SelectExpressions. I ask because as I am writing and fixing tests for some complex GroupBy queries, I'm seeing that MemberAccessBindingExpressionVisitor is going to need to be able to bind grouping keys, which means they need to be present in the SelectExpression, which means there is going to have to be some duplicate grouping key processing logic going on between the two visitors as it stands.

    EDIT: Think I have something working for now that's not too awful but I'll leave these thoughts here anyways...

  4. smitpatel commented on Mar 28, 2017

    @smitpatel
    Contributor

    TableExpressionBase Alias & QuerySource both are nullable & settable. Review.
    Same for PredicateJoinExpressionBase

  5. smitpatel commented on Mar 28, 2017

    @smitpatel
    Contributor

    FromSqlExpression.Arguments is not a collection property, just Expression. Review property name.

  6. smitpatel commented on Mar 29, 2017

    @smitpatel
    Contributor

    Eliminate IsProjectStar by introducing an expression in SelectExpression.Projection representing star projection.

  7. tuespetre commented on Apr 12, 2017

    @tuespetre
    Contributor

    I have an idea to simplify/streamline a good chunk of code around shaped queries, parameter injection, and similar (possibly includes but I'm not up to speed on how that feature has been evolving.) Basically, represent all of these 'special method call expressions' as reducible extension expressions that carry appropriate metadata with them: for instance, ShapedQueryExpression, which carries with it a SelectExpression and a Shaper, and when Reduce() is called, it reduces down to the appropriate MethodCallExpression.

    By doing this, the codebase can move away from a lot of the trickiness of digging into MethodCallExpressions to inspect their methods and arguments and perform surgery on them, and towards a more 'expressive' way that encapsulates that kind of logic in one place.

    I think the code will better explain itself so I will submit a PR to demonstrate the idea using ShapedQueryExpression.

  8. anpete commented on Apr 12, 2017

    @anpete
    ContributorAuthor

    This sounds good. We have discussed changes like this internally, too. Look forward to the PR.

  9. tuespetre commented on Apr 14, 2017

    @tuespetre
    Contributor

    More ideas for building a richer expression tree:

    • Instead of having SqlTranslatingExpressionVisitor return null and have a ClientEvalPredicate property, have it return expressions that can be used with pattern matching for a more functional processing style:
      • SqlTranslatableExpression
      • SqlUntranslatableExpression
      • SqlPartiallyTranslatableExpression with TranslatableExpression and UntranslatableExpression properties to represent an AndAlso expression with a translatable side and an untranslatable side
    • Perform some kind of pre-processing that wraps certain types of expression patterns into first-class extension expressions in order to eliminate some of the need to constantly refer back to the query model visitor for member and method binding, for example:
      • EntityReferenceExpression
      • MappedPropertyExpression
      • UnmappedPropertyExpression
  10. modified the milestones: , 2.0.0 on Apr 19, 2017
  11. 7 remaining items

  12. modified the milestones: Backlog, 3.0.0 on Sep 1, 2018
  13. smitpatel commented on Sep 1, 2018

    @smitpatel
    Contributor

    Pulling this into 3.0 since we should either finish this with #12795 or close this.

  14. modified the milestones: 3.0.0, on Jun 5, 2019
  15. smitpatel commented on Jun 5, 2019

    @smitpatel
    Contributor

    We have done whatever was relevant here in new pipeline. Closing as fixed.

  16. modified the milestones: , 3.0.0 on Nov 11, 2019
  17. added theissue type on Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions