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 GetQueryResult <TProjection>(IDocumentQuery <TProjection> finalQuery)
        {
            switch (queryType)
            {
            case SpecialQueryType.First:
            {
                return(finalQuery.First());
            }

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

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

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

            case SpecialQueryType.All:
            {
                var pred = predicate.Compile();
                return(finalQuery.AsQueryable().All(projection => pred((T)(object)projection)));
            }

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

#if !SILVERLIGHT
            case SpecialQueryType.Count:
            {
                var queryResultAsync = finalQuery.QueryResult;
                return(queryResultAsync.TotalResults);
            }
#else
            case SpecialQueryType.Count:
            {
                throw new NotImplementedException("not done yet");
            }
#endif
            default:
            {
                return(finalQuery);
            }
            }
        }