private T InvokeExecuteOnEval(IEnumerable result) { // We get the required element type of ExecuteOnEval and cast the result enumerable var elementType = ExecuteOnEval.Method.GetParameters()[1].ParameterType.GetGenericArguments()[0]; // When not null, ExecuteOnEval is fetched with PostExecuteTransformer from IntermediateHqlTree // through ExpressionToHqlTranslationResults, which requires a IQueryable as input and directly // yields the scalar result when the query is scalar. return((T)ExecuteOnEval.DynamicInvoke(MakeQueryableHelper.MakeQueryable(result, elementType))); }
public async Task <T> GetValueAsync(CancellationToken cancellationToken = default(CancellationToken)) { var result = await _getResultAsync(cancellationToken).ConfigureAwait(false); if (ExecuteOnEval != null) { // When not null, ExecuteOnEval is fetched with PostExecuteTransformer from IntermediateHqlTree // through ExpressionToHqlTranslationResults, which requires a IQueryable as input and directly // yields the scalar result when the query is scalar. return((T)ExecuteOnEval.DynamicInvoke(result.AsQueryable())); } return(result.FirstOrDefault()); }