private static string CalculateKeyPart(CriteriaOperator source)
        {
            var operandProperty = source as OperandProperty;

            if (operandProperty != null)
            {
                return operandProperty.PropertyName;
            }

            throw new NotSupportedException("Не поддерживаем CriteriaOperator отличный от 'OperandProperty'. Переданное значение CriteriaOperator: '{0}'".FillWith(source.TypeName()));
        }
        private static string CalculateKeyPart(CriteriaOperator source)
        {
            var operandProperty = source as OperandProperty;

            if (operandProperty != null)
            {
                return(operandProperty.PropertyName);
            }

            throw new NotSupportedException("Не поддерживаем CriteriaOperator отличный от 'OperandProperty'. Переданное значение CriteriaOperator: '{0}'".FillWith(source.TypeName()));
        }
Ejemplo n.º 3
0
        private string InterpritateExpression(CriteriaOperator source)
        {
            var operandProperty = source as OperandProperty;

            if (operandProperty != null)
            {
                var propertyName = operandProperty.PropertyName;
                var propertyType = typeof(T).GetPropertyType(propertyName);

                if (propertyType.Implements <IEnumerable>())
                {
                    throw new NotSupportedException("Не поддерживаем вычисление summary над property, которое является какого-либо рода \"перечислением\"");
                }


                var result = string.Empty;

                if (SpecialMappings.ContainsKey(propertyName))
                {
                    var specialMapping = SpecialMappings[propertyName];

                    if (specialMapping.Contains(BaseAlias))
                    {
                        result = specialMapping;
                    }
                    else
                    {
                        result = BaseAlias + "." + specialMapping;
                    }
                }
                else
                {
                    result = BaseAlias + "." + propertyName;
                }

                return(result);
            }

            throw new NotSupportedException("Не поддерживаем CriteriaOperator отличный от 'OperandProperty'. Переданное значение CriteriaOperator: '{0}'".FillWith(source.TypeName()));
        }
        private string InterpritateFilter(CriteriaOperator source, string currentAlias)
        {
            var groupOperator = source as GroupOperator;

            if (groupOperator != null)
            {
                return ProcessGroupOperator(groupOperator, currentAlias);
            }

            var inOperator = source as InOperator;

            if (inOperator != null)
            {
                return ProcessInOperator(inOperator, currentAlias);
            }

            var aggregateOperand = source as AggregateOperand;

            if (aggregateOperand != null)
            {
                return ProcessAggregateOperand(aggregateOperand, currentAlias);
            }

            var binaryOperator = source as BinaryOperator;

            if (binaryOperator != null)
            {
                return ProcessBinaryOperator(binaryOperator, currentAlias);
            }

            var operandProperty = source as OperandProperty;

            if (operandProperty != null)
            {
                return ProcessOperandProperty(operandProperty, currentAlias);
            }

            var constantValue = source as ConstantValue;

            if (constantValue != null)
            {
                return ProcessConstantValue(constantValue);
            }

            var operandValue = source as OperandValue;

            if (operandValue != null)
            {
                return ProcessOperandValue(operandValue);
            }

            throw new NotSupportedException("Не поддерживаем CriteriaOperator отличный от 'GroupOperator', 'AggregateOperand', 'BinaryOperator', 'OperandProperty', 'ConstantValue'. Переданное значение CriteriaOperator: '{0}'".FillWith(source.TypeName()));
        }
Ejemplo n.º 5
0
        public int LocateByValue(CriteriaOperator expression, object value, int startIndex, bool searchUp)
        {
            // ReSharper disable ConditionIsAlwaysTrueOrFalse

            if (startIndex != -1)
            {
                throw new NotSupportedException("Не поддерживаем значение StartIndex отличное от '-1'. Переданное значение StartIndex: '{0}'".FillWith(startIndex));
            }

            if (searchUp)
            {
                throw new NotSupportedException("Не поддерживаем значение SearchUp отличное от 'false'. Переданное значение SearchUp: '{0}'".FillWith(searchUp));
            }

            // ReSharper restore ConditionIsAlwaysTrueOrFalse


            var operandProperty = expression as OperandProperty;

            if (operandProperty != null)
            {
                var propertyDelegate = PropertyManager.Get(operandProperty.PropertyName).Delegate();

                return(RowsRepositoryCache.Value.FindIndex(x => propertyDelegate.Invoke(x).Equals(value)));
            }

            throw new NotSupportedException("Не поддерживаем значение Expression отличное от 'OperandProperty'. Переданное значение Expression: '{0}'".FillWith(expression.TypeName()));
        }
        private string InterpritateFilter(CriteriaOperator source, string currentAlias)
        {
            var groupOperator = source as GroupOperator;

            if (groupOperator != null)
            {
                return(ProcessGroupOperator(groupOperator, currentAlias));
            }


            var inOperator = source as InOperator;

            if (inOperator != null)
            {
                return(ProcessInOperator(inOperator, currentAlias));
            }


            var aggregateOperand = source as AggregateOperand;

            if (aggregateOperand != null)
            {
                return(ProcessAggregateOperand(aggregateOperand, currentAlias));
            }


            var binaryOperator = source as BinaryOperator;

            if (binaryOperator != null)
            {
                return(ProcessBinaryOperator(binaryOperator, currentAlias));
            }


            var operandProperty = source as OperandProperty;

            if (operandProperty != null)
            {
                return(ProcessOperandProperty(operandProperty, currentAlias));
            }


            var constantValue = source as ConstantValue;

            if (constantValue != null)
            {
                return(ProcessConstantValue(constantValue));
            }


            var operandValue = source as OperandValue;

            if (operandValue != null)
            {
                return(ProcessOperandValue(operandValue));
            }



            throw new NotSupportedException("Не поддерживаем CriteriaOperator отличный от 'GroupOperator', 'AggregateOperand', 'BinaryOperator', 'OperandProperty', 'ConstantValue'. Переданное значение CriteriaOperator: '{0}'".FillWith(source.TypeName()));
        }