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
};
The fix for #12697 enables using a method defined like this in a query:
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: