ClosureMaterializer
Walks a MemberExpression chain that ultimately roots at a ConstantExpression and dereferences it via reflection, turning closure captures (compiler-generated DisplayClass fields) of any depth into a single materialised value. Replaces three independent inline branches that previously lived in the translator's VisitMember — one for direct DisplayClass fields, one for two-level captures, and one for nested DisplayClass chains — with a single unified path. Callers feed the result into the translator's emission helper so the captured value becomes a SQL parameter (or, for IQueryable captures, a re-visited subquery) instead of leaking the local-variable name as a raw column reference.
Методы
public static bool TryEvaluate(MemberExpression member, object value)
result = ClosureMaterializer.TryEvaluate(member, value)
Tries to materialise as a constant value.
- member
- Leaf MemberExpression.
- value
- Materialised value when the chain is rooted at a constant. May be when the captured value itself is null — inspect the return value, not the out parameter, to distinguish "couldn't materialise" from "materialised to null".
Возвращает: when the entire chain dereferenced cleanly. for any unsupported root (parameter, method call, etc.) — callers must fall through to the column-emission branches in that case.