Class EagerEvaluationAttribute
Marks an IQueryable-returning extension method whose call should be evaluated on the client during expression tree exposure, regardless of the shape of its source argument. The returned queryable's expression replaces the original method call before query translation.
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public sealed class EagerEvaluationAttribute : Attribute, _Attribute
- Inheritance
-
objectEagerEvaluationAttribute
- Implements
- Inherited Members
- Extension Methods
Remarks
Use this on syntactic-sugar overloads that normalise themselves into a richer internal
call (for example AsCte(Action<ICteBuilder>) which desugars to
AsCteInternal(CteAnnotationsContainer)). Without this marker, the exposer only
evaluates calls whose first argument is a MemberExpression
or ConstantExpression; lambda-captured calls with
a method-chain source would never get the client-side rewrite.
A method marked with this attribute may be invoked more than once per IQueryable materialization — expression tree rewrites (other visitors, re-exposure after transformation) can cause the exposer to run again. Marked methods and any delegates they invoke (builder callbacks, etc.) must therefore be pure and idempotent: no observable side effects beyond constructing the replacement expression tree.
The attribute is observed only by the in-box LinqToDB.Internal.Linq.Builder.Visitors.ExposeExpressionVisitor. Custom IQueryProvider implementations that do not route through the linq2db exposer will not desugar methods tagged with this attribute.
The exposer throws LinqToDBException when a marked method appears with arguments that cannot be client-evaluated (captured non-compilable values). Silently dropping such calls would lose the user's configuration, so the failure is surfaced explicitly.