Пример #1
0
        private dynamic ComboEqualsOperator(ComplexAdvancedSearchRequest item, int index)
        {
            var          eo = new ExpandoObject();
            OperatorName op = (OperatorName)item.SearchRequest.Operator.OperatorType;

            eo.TryAdd <string, object>($"{item.SearchRequest.Attribute.AttributeName}{index}", ((JObject)item.SearchRequest.Value).Value <string>("value"));
            string extraCondition = "";

            if (item.Prefix != "")
            {
                item.Prefix += ".";
            }

            foreach (var cond in item.AdditionalCondition)
            {
                extraCondition += $" AND {item.Prefix}{cond.Key}=@{cond.Key}{index}";
                eo.TryAdd <string, object>($"{cond.Key}{index}", cond.Value);
            }

            return(new
            {
                sql = $"({item.Prefix}{item.SearchRequest.Attribute.AttributeName}=@{item.SearchRequest.Attribute.AttributeName}{index} {extraCondition})",
                value = eo
            });
        }
Пример #2
0
        private dynamic ComboInOperator(ComplexAdvancedSearchRequest item, int index)
        {
            var          eo = new ExpandoObject();
            OperatorName op = (OperatorName)item.SearchRequest.Operator.OperatorType;

            if (item.Prefix != "")
            {
                item.Prefix += ".";
            }

            var lst = new List <string>();

            try
            {
                JArray array = (JArray)item.SearchRequest.Value;
                foreach (var ar in array)
                {
                    lst.Add(ar.Value <string>("value"));
                }
            }
            catch (Exception)
            {
                var obj = (JObject)item.SearchRequest.Value;
                lst.Add(obj.Value <string>("value"));
            }


            eo.TryAdd <string, object>($"{item.SearchRequest.Attribute.AttributeName}{index}", lst);

            string extraCondition = "";

            foreach (var cond in item.AdditionalCondition)
            {
                extraCondition += $" AND {item.Prefix}{cond.Key}=@{cond.Key}{index}";
                eo.TryAdd <string, object>($"{cond.Key}{index}", cond.Value);
            }

            return(new
            {
                sql = $"({item.Prefix}{item.SearchRequest.Attribute.AttributeName} in @{item.SearchRequest.Attribute.AttributeName}{index} {extraCondition})",
                value = eo
            });
        }
Пример #3
0
        private dynamic getComplexFieldQuery(ComplexAdvancedSearchRequest item, int index)
        {
            OperatorName op = (OperatorName)item.SearchRequest.Operator.OperatorName;

            switch (op)
            {
            case OperatorName.ComboEquals:
                return(ComboEqualsOperator(item, index));

            case OperatorName.ComboIn:
                return(ComboInOperator(item, index));

            //case OperatorName.DateTimeBetween:
            //    return DateTimeBetweenOperator(item);
            //case OperatorName.DateTimeEquals:
            //    return DateTimeEqualsOperator(item);
            //case OperatorName.DateTimeGreaterThan:
            //    return DateTimeGreaterThanOperator(item);
            //case OperatorName.DateTimeGreaterThanOrEquals:
            //    return DateTimeGreaterThanOrEqualsOperator(item);
            //case OperatorName.DateTimeIn:
            //    return DateTimeInOperator(item);
            //case OperatorName.DateTimeLessThan:
            //    return DateTimeLessThanOperator(item);
            //case OperatorName.DateTimeLessThanOrEquals:
            //    return DateTimeLessThanOrEqualsOperator(item);
            //case OperatorName.DateTimeNotEquals:
            //    return DateTimeNotEqualsOperator(item);
            //case OperatorName.DecimalBetween:
            //    return DecimalBetweenOperator(item);
            //case OperatorName.DecimalEquals:
            //    return DecimalEqualsOperator(item);
            //case OperatorName.DecimalGreaterThan:
            //    return DecimalGreaterThanOperator(item);
            //case OperatorName.DecimalGreaterThanOrEquals:
            //    return DecimalGreaterThanOrEqualsOperator(item);
            //case OperatorName.DecimalIn:
            //    return DecimalInOperator(item);
            //case OperatorName.DecimalLessThan:
            //    return DecimalLessThanOperator(item);
            //case OperatorName.DecimalLessThanOrEquals:
            //    return DecimalLessThanOrEqualsOperator(item);
            //case OperatorName.DecimalNotEquals:
            //    return DecimalNotEqualsOperator(item);
            //case OperatorName.IntegerBetween:
            //    return IntegerBetweenOperator(item);
            //case OperatorName.IntegerEquals:
            //    return IntegerEqualsOperator(item);
            //case OperatorName.IntegerGreaterThan:
            //    return IntegerGreaterThanOperator(item);
            //case OperatorName.IntegerGreaterThanOrEquals:
            //    return IntegerGreaterThanOrEqualsOperator(item);
            //case OperatorName.IntegerIn:
            //    return IntegerInOperator(item);
            //case OperatorName.IntegerLessThan:
            //    return IntegerLessThanOperator(item);
            //case OperatorName.IntegerLessThanorEquals:
            //    return IntegerLessThanorEqualsOperator(item);
            //case OperatorName.IntegerNotEquals:
            //    return IntegerNotEqualsOperator(item);
            //case OperatorName.MultiCheckboxEquals:
            //    return MultiCheckboxEqualsOperator(item);
            //case OperatorName.MultiCheckboxIn:
            //    return MultiCheckboxInOperator(item);
            //case OperatorName.StringEquals:
            //    return StringEqualsOperator(item);
            //case OperatorName.StringGreaterThan:
            //    return StringGreaterThanOperator(item);
            //case OperatorName.StringIn:
            //    return StringInOperator(item);
            //case OperatorName.StringLessThan:
            //    return StringLessThanOperator(item);
            //case OperatorName.StringLike:
            //    return StringLikeOperator(item);
            //case OperatorName.StringNotEquals:
            //    return StringNotEqualsOperator(item);
            //case OperatorName.RadioEquals:
            //    return RadioEqualsOperator(item);
            default:
                return("");
            }
        }