/// <summary> /// Register the query as a lazy async query in the session and return a lazy async /// instance that will evaluate the query only when needed /// </summary> public Lazy <Task <IEnumerable <S> > > LazilyAsync <S>(Expression expression, Action <IEnumerable <S> > onEval) { var processor = GetQueryProviderProcessor <S>(); var query = processor.GetDocumentQueryForAsync(expression); if (afterQueryExecuted != null) { query.AfterQueryExecuted(afterQueryExecuted); } var renamedFields = FieldsToFetch.Select(field => { var renamedField = FieldsToRename.FirstOrDefault(x => x.OriginalField == field); if (renamedField != null) { return(renamedField.NewField ?? field); } return(field); }).ToArray(); if (renamedFields.Length > 0) { query.AfterQueryExecuted(processor.RenameResults); } if (FieldsToFetch.Count > 0) { query = query.SelectFields <S>(FieldsToFetch.ToArray(), renamedFields); } return(query.LazilyAsync(onEval)); }
/// <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 Lazy <IEnumerable <S> > Lazily <S>(Expression expression, Action <IEnumerable <S> > onEval) { var processor = GetQueryProviderProcessor <S>(); var query = processor.GetLuceneQueryFor(expression); if (afterQueryExecuted != null) { query.AfterQueryExecuted(afterQueryExecuted); } var renamedFields = FieldsToFetch.Select(field => { string value; if (FieldsToRename.TryGetValue(field, out value) && value != null) { return(value); } return(field); }).ToArray(); if (renamedFields.Length > 0) { query.AfterQueryExecuted(processor.RenameResults); } if (FieldsToFetch.Count > 0) { query = query.SelectFields <S>(FieldsToFetch.ToArray(), renamedFields); } return(query.Lazily(onEval)); }
public Lazy <IEnumerable <S> > Lazily <S>(Expression expression, Action <IEnumerable <S> > onEval) { var processor = GetQueryProviderProcessor <S>(); var query = processor.GetLuceneQueryFor(expression); if (afterQueryExecuted != null) { query.AfterQueryExecuted(afterQueryExecuted); } if (FieldsToFetch.Count > 0) { query = query.SelectFields <S>(FieldsToFetch.ToArray()); } return(query.Lazily(onEval)); }
private object ExecuteQuery <TProjection>() { var finalQuery = ((IDocumentQuery <T>)luceneQuery).SelectFields <TProjection>(FieldsToFetch.ToArray()); if (FieldsToRename.Count > 0) { finalQuery.AfterQueryExecuted(RenameResults); } var executeQuery = GetQueryResult(finalQuery); var queryResult = finalQuery.QueryResult; if (afterQueryExecuted != null) { afterQueryExecuted(queryResult); } return(executeQuery); }