Exemplo n.º 1
0
        public object Execute(Expression expression)
        {
            chainedWhere = false;
            ProcessExpression(expression);

            luceneQuery = luceneQuery.SelectFields <T>(FieldsToFetch.ToArray());

            if (customizeQuery != null)
            {
                customizeQuery(luceneQuery);
            }

            switch (queryType)
            {
            case SpecialQueryType.First:
            {
                return(luceneQuery.First());
            }

            case SpecialQueryType.FirstOrDefault:
            {
                return(luceneQuery.FirstOrDefault());
            }

            case SpecialQueryType.Single:
            {
                return(luceneQuery.Single());
            }

            case SpecialQueryType.SingleOrDefault:
            {
                return(luceneQuery.SingleOrDefault());
            }

            case SpecialQueryType.All:
            {
                return(luceneQuery.AsQueryable().All(this.predicate));
            }

            case SpecialQueryType.Any:
            {
                return(luceneQuery.Any());
            }

            case SpecialQueryType.Count:
            {
                return(luceneQuery.QueryResult.TotalResults);
            }

            default:
            {
                return(luceneQuery);
            }
            }
        }
        private object ExecuteQuery <TProjection>()
        {
            var finalQuery = luceneQuery.SelectFields <TProjection>(FieldsToFetch.ToArray());

            var executeQuery = GetQueryResult(finalQuery);

            var queryResult = finalQuery.QueryResult;

            if (afterQueryExecuted != null)
            {
                afterQueryExecuted(queryResult);
            }

            return(executeQuery);
        }
Exemplo n.º 3
0
 public static IDocumentQuery <TS> Projection <T, TS>(this IDocumentQuery <T> query)
 {
     return(query.SelectFields <TS>(typeof(TS).GetProperties().Select(x => x.Name).ToArray()));
 }