/// <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);
        }
Esempio n. 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);
        }
Esempio n. 3
0
 static LinqDeferConfiguration()
 {
     DefaultConfiguration = new LinqDeferConfiguration(() => new DataAccessOnlyAnalyser());
 }
 private DeferProvider(IQueryProvider innerProvider, LinqDeferConfiguration config)
 {
     _innerProvider = innerProvider;
     _config        = config;
 }