コード例 #1
0
        public TResult To <TResult>(Func <IQueryable <TDest>, TResult> runAction)
        {
            var result = runAction(GetDestQuery());

            if (result is Task)
            {
                //Only Task<T> tasks are valid
                if (result.GetType() == typeof(Task))
                {
                    throw new ApplicationException("QueryMaterializer: The task is not valid because it doesn't produce any result.");
                }

                return((TResult)MaterializeTask((dynamic)result));
            }

            return(Materializer.ApplyAfterMap(result, _materializerContext));
        }
コード例 #2
0
 private Task <TResult> MaterializeTask <TResult>(Task <TResult> resultTask)
 {
     return(resultTask.ContinueWith(t => Materializer.ApplyAfterMap(t.Result, _materializerContext), TaskContinuationOptions.OnlyOnRanToCompletion));
 }