protected PropertyAccessResult GetProperty(Expression entity, string propertyName)
        {
            var entityType = typeof(TDto);

            var sanitizedPropertyName = propertyName.ToTitleCase();

            var propertyAccessResult = _propertyAccessStrategy.Execute(entity, entityType, sanitizedPropertyName);

            return(propertyAccessResult);
        }
        public IQueryable <TEntity> OrderBy(IQueryable <TEntity> collection, string fieldName, string direction)
        {
            var entityType = (typeof(TEntity));

            var sanitizedFieldName = fieldName.ToTitleCase();

            var propertyAccessResult = _propertyAccessStrategy.Execute(Expression.Parameter(entityType), entityType, sanitizedFieldName);

            var expressionBuilder = _orderExpressionBuilderLocator.GetOrderExpressionBuilder(propertyAccessResult.PropertyType);

            var orderExpression = expressionBuilder.Build(collection, fieldName, direction);

            return(orderExpression);
        }
        public Expression CreateFilterExpression(Expression entity, string property, string @operator, string value)
        {
            var propertyAccess = _propertyAccessStrategy.Execute(entity, typeof(TDto), property);

            var propertyType       = propertyAccess.PropertyType;
            var propertyExpression = propertyAccess.PropertyAccessExpression;

            var valueExpression = _valueExpressionService.GetValueExpression(value, propertyType);

            var filterExpressionFactory = _operatorExpressionFactoryService.GetExpressionFactory(@operator, propertyType);

            var result = filterExpressionFactory.Create(propertyExpression, valueExpression);

            return(result);
        }
Exemple #4
0
        public PropertyAccessResult Execute(Expression entity, Type entityType, string propertyName)
        {
            if (_strategy == null)
            {
                return(null);
            }

            var rawResult = _strategy.Execute(entity, entityType, propertyName);

            if (rawResult == null)
            {
                return(null);
            }

            var result = Decorate(rawResult);

            return(result);
        }