/// <inheritdoc /> public Lazy <Task <IEnumerable <T> > > LazilyAsync(Action <IEnumerable <T> > onEval = null) { if (QueryOperation == null) { QueryOperation = InitializeQueryOperation(); } var lazyQueryOperation = new LazyQueryOperation <T>(TheSession.Conventions, QueryOperation, AfterQueryExecutedCallback); return(((AsyncDocumentSession)TheSession).AddLazyOperation(lazyQueryOperation, onEval)); }
/// <inheritdoc /> public Lazy <Task <int> > CountLazilyAsync(CancellationToken token = default(CancellationToken)) { if (QueryOperation == null) { Take(0); QueryOperation = InitializeQueryOperation(); } var lazyQueryOperation = new LazyQueryOperation <T>(TheSession.Conventions, QueryOperation, AfterQueryExecutedCallback); return(((AsyncDocumentSession)TheSession).AddLazyCountOperation(lazyQueryOperation, token)); }
/// <summary> /// Register the query as a lazy-count query in the session and return a lazy /// instance that will evaluate the query only when needed /// </summary> public Lazy <Task <int> > CountLazilyAsync(CancellationToken token = default(CancellationToken)) { if (queryOperation == null) { ExecuteBeforeQueryListeners(); Take(0); queryOperation = InitializeQueryOperation(); } var lazyQueryOperation = new LazyQueryOperation <T>(queryOperation, afterQueryExecutedCallback, includes, AsyncDatabaseCommands.OperationsHeaders); return(((AsyncDocumentSession)theSession).AddLazyCountOperation(lazyQueryOperation, token)); }
/// <inheritdoc /> public Lazy <int> CountLazily() { if (QueryOperation == null) { Take(0); QueryOperation = InitializeQueryOperation(); } var lazyQueryOperation = new LazyQueryOperation <T>(TheSession.Conventions, QueryOperation, AfterQueryExecutedCallback); return(((DocumentSession)TheSession).AddLazyCountOperation(lazyQueryOperation)); }
/// <summary> /// Register the query as a lazy-count query in the session and return a lazy /// instance that will evaluate the query only when needed /// </summary> public Lazy <Task <int> > CountLazilyAsync() { var headers = new Dictionary <string, string>(); if (queryOperation == null) { ExecuteBeforeQueryListeners(); Take(0); queryOperation = InitializeQueryOperation((key, val) => headers[key] = val); } var lazyQueryOperation = new LazyQueryOperation <T>(queryOperation, afterQueryExecutedCallback, includes); lazyQueryOperation.SetHeaders(headers); return(((AsyncDocumentSession)theSession).AddLazyCountOperation(lazyQueryOperation)); }
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(); } var lazyQueryOperation = new LazyQueryOperation <T>(queryOperation, afterQueryExecutedCallback, includes, ShardDatabaseCommands.First().OperationsHeaders); return(lazyQueryOperation); }
/// <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)); }