예제 #1
0
        /// <summary>
        /// Wraps and processes the supplied query for deferred evaluation
        /// </summary>
        /// <param name="query"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static IQueryable Wrap(IQueryable query, LinqDeferConfiguration config)
        {
            var provider     = new DeferProvider(query.Provider, config);
            var wrappedQuery = provider.CreateQuery(query.Expression);

            return(wrappedQuery);
        }
예제 #2
0
        /// <summary>
        /// Causes the preceeding query expression to be searched for instances of calls to
        /// Defer.Eval() and transformed.
        /// The query will run as usual, but with expressions with Defer.Eval() being evaluated
        /// after the required information is retrieved using the underlying provider.
        /// This method performs materialisation (the query will be run).  The underlying IQueryable
        /// can be retrieved by using DeferProvider.Wrap directly.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static IEnumerable <T> ThenDoDeferred <T>(this IQueryable <T> query, LinqDeferConfiguration config = null)
        {
            config = config ?? LinqDeferConfiguration.Default;

            var wrappedQuery        = DeferProvider.Wrap(query, config);
            var materialisedResults = wrappedQuery.ToList();

            return(materialisedResults);
        }
예제 #3
0
 /// <summary>
 /// Creates a new instance of DeferWrappedQuery
 /// </summary>
 /// <param name="provider">The DeferProvider instance to use</param>
 /// <param name="expression">The untransformed source expression</param>
 public DeferWrappedQuery(DeferProvider provider, Expression expression)
 {
     _provider   = provider;
     _expression = expression;
 }