public IEnumerable <T> ExecuteEnumerable <T>(Expression expression)
        {
            var chain          = ExpressionToMetadataConverter.Convert(expression, _elementType);
            var dataCollection = LoadDataCollection(chain);
            var models         = LoadModelCollection(dataCollection, chain);

            return(ApplyCollectionProjector <T>(models.ToList <object>(), chain));
        }
        private T ExecuteScalar <T>(Expression expression)
        {
            var chain          = ExpressionToMetadataConverter.Convert(expression, _elementType);
            var dataCollection = LoadDataCollection(chain);

            if (RepositoryExpressionUtilities.IsAggregationMethodExpression(expression))
            {
                return(GetAggregationValue <T>(expression, dataCollection));
            }
            if (RepositoryExpressionUtilities.IsAnyMethodExpression(expression))
            {
                return(GetAnyValue <T>(dataCollection));
            }
            var models = LoadModelCollection(dataCollection, chain);

            return(ApplyScalarProjector <T>(models.ToList <object>(), chain));
        }