コード例 #1
0
        private static T GetAggregationValue <T>(Expression expression, IReadOnlyCollection <Dictionary <string, object> > dataCollection)
        {
            var methodName = RepositoryExpressionUtilities.GetMethodName(expression);
            var columnName = RepositoryExpressionUtilities.GetAggregationColumnName(methodName);

            return(GetAggregationValue <T>(columnName, dataCollection));
        }
コード例 #2
0
        private static T GetAnyValue <T>(IReadOnlyCollection <Dictionary <string, object> >
                                         dataCollection)
        {
            var columnName = RepositoryExpressionUtilities.GetAnyColumnName();
            var count      = GetAggregationValue <int>(columnName, dataCollection);
            var value      = count > 0;

            if (value is T typedValue)
            {
                return(typedValue);
            }

            return(default(T));
        }
コード例 #3
0
        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));
        }