Skip to content
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

Query: Consider adding method to force client evaluation of an expression #12736

Closed
divega opened this issue Jul 20, 2018 · 3 comments
Closed
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed.

Comments

@divega
Copy link
Contributor

divega commented Jul 20, 2018

The fix for #12697 enables using a method defined like this in a query:

public static T Client<T>(T s) => s;

The point being that the method is opaque to our query translator and therefore forces client evaluation. I want to suggest that we consider adding a method like that somewhere under the static EF class for better discoverability.

I haven't tested how well it works and I am not sure I understand all the implications but ideally this could be used both on the way in (to force funcletization of an expression that would otherwise be translated, i.e. a shortcut for having to write the expression outside the query) and on the way out (force client evaluation of an expression that would otherwise be translated).

Example usage:

                var data = (from c in db.Checks
                                 join ct in db.CheckTemplates
                                      .Include(a => a.Implementers).ThenInclude(u => u.User)
                                 on c.CheckTemplateId equals ct.CheckTemplateId
                                 where c.CheckId == checkId
                                 select new
                                 {
                                     CheckId = c.CheckId,
                                     Description = ct.Description,
                                     Implementers = EF.Client(ct).Implementers,
                                     NumExaminers = ct.Examiners.Count
                                 };
@pmiddleton
Copy link
Contributor

Could users misunderstand the feature and try passing a lambda to the Client method that references column data? That won't be executable client side.

@divega
Copy link
Contributor Author

divega commented Jul 20, 2018

@pmiddleton that is a reason to come up with a good name. Worst case that would cause N+1 queries (or throw).

@ajcvickers
Copy link
Member

Tracking this as part of 3.0 query behaviors, so added to #12795

@ajcvickers ajcvickers added this to the 3.0.0 milestone Jul 30, 2018
@ajcvickers ajcvickers removed this from the 3.0.0 milestone Jan 23, 2019
@smitpatel smitpatel removed their assignment Jan 12, 2022
@ajcvickers ajcvickers added the closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. label Mar 10, 2022
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed.
Projects
None yet
Development

No branches or pull requests

4 participants