コード例 #1
0
        /// <summary>
        /// Register the query as a lazy query in the session and return a lazy
        /// instance that will evaluate the query only when needed
        /// </summary>
        public override Lazy <IEnumerable <T> > Lazily(Action <IEnumerable <T> > onEval)
        {
            if (queryOperation == null)
            {
                foreach (var databaseCommands11 in ShardDatabaseCommands)
                {
                    foreach (var key in databaseCommands11.OperationsHeaders.AllKeys.Where(key => key.StartsWith("SortHint")).ToArray())
                    {
                        databaseCommands11.OperationsHeaders.Remove(key);
                    }
                }

                ExecuteBeforeQueryListeners();
                queryOperation = InitializeQueryOperation((s, s1) => ShardDatabaseCommands.ForEach(cmd => cmd.OperationsHeaders.Set(s, s1)));
            }

            var lazyQueryOperation = new LazyQueryOperation <T>(queryOperation, afterQueryExecutedCallback);

            return(((ShardedDocumentSession)theSession).AddLazyOperation(lazyQueryOperation, onEval, ShardDatabaseCommands));
        }
コード例 #2
0
        private LazyQueryOperation <T> ProcessLazyQuery()
        {
            if (queryOperation == null)
            {
                foreach (var databaseCommands11 in ShardDatabaseCommands)
                {
                    foreach (var key in databaseCommands11.OperationsHeaders.AllKeys.Where(key => key.StartsWith("SortHint")).ToArray())
                    {
                        databaseCommands11.OperationsHeaders.Remove(key);
                    }
                }

                ExecuteBeforeQueryListeners();
                queryOperation = InitializeQueryOperation((s, s1) => ShardDatabaseCommands.ForEach(cmd => cmd.OperationsHeaders.Set(s, s1)));
            }

            var lazyQueryOperation = new LazyQueryOperation <T>(queryOperation, afterQueryExecutedCallback, includes);

            return(lazyQueryOperation);
        }