Exemplo n.º 1
0
        internal IQueryJoinableAnd AddConditionCorrelation(String correlation, QueryConditionTypes type, String matchCorrelation)
        {
            LocalQueryConditionCorrelation condition = new LocalQueryConditionCorrelation();

            condition.Correlation      = correlation;
            condition.Type             = type;
            condition.MatchCorrelation = matchCorrelation;
            condition.Ordinal          = this.Conditions.Count + 1;
            this.Conditions.Add(condition);
            return(this);
        }
Exemplo n.º 2
0
        internal IQueryJoinableAnd AddConditionValue(String correlation, QueryConditionTypes type, Object value)
        {
            LocalQueryConditionValue condition = new LocalQueryConditionValue();

            condition.Correlation     = correlation;
            condition.Type            = type;
            condition.Value           = value;
            condition.Ordinal         = this.Conditions.Count + 1;
            condition.ParameterPrefix = String.Concat("join", this.Ordinal, "param");
            this.Conditions.Add(condition);
            return(this);
        }
Exemplo n.º 3
0
 IQueryConditionableAnd IQueryConditionable.WhereCorrelation(String correlation, QueryConditionTypes type, String matchCorrelation)
 {
     return(this.QueryModel.AddConditionCorrelation(correlation, type, matchCorrelation));
 }
Exemplo n.º 4
0
 IQueryConditionableAnd IQueryConditionable.Where(String correlation, QueryConditionTypes type, Object value)
 {
     return(this.QueryModel.AddConditionValue(correlation, type, value));
 }
Exemplo n.º 5
0
 IQueryJoinableAnd IQueryJoinableAnd.AndCorrelation(String correlation, QueryConditionTypes type, String matchCorrelation)
 {
     return(this.AddConditionCorrelation(correlation, type, matchCorrelation));
 }
Exemplo n.º 6
0
 IQueryJoinableAnd IQueryJoinableAnd.And(String correlation, QueryConditionTypes type, Object value)
 {
     return(this.AddConditionValue(correlation, type, value));
 }
Exemplo n.º 7
0
        /// <summary>
        ///     Constructs the query that will execute the search.
        /// </summary>
        private ISearchesRunnable ConstructCondition(IQueryConditionable query)
        {
            IEnumerable <HtmlGenericControl>     criteriaRows = this.SearchCriteria.Controls.OfType <HtmlGenericControl>();
            IQueryConditionableAnd               conditions   = null;
            IEnumerable <Search.SearchParameter> parameters   = this.SearchType.Parameters.OfType <Search.SearchParameter>().Where(param => param.Type == SearchParameterTypes.Standard || param.Type == SearchParameterTypes.Exclusion);

            foreach (Search.SearchParameter parameter in parameters)
            {
                Object conditionValue  = null;
                string searchFieldName = parameter.FieldName;
                switch (parameter.FieldType)
                {
                case "textbox":
                case "jslookup": conditionValue = this.ConstructCondition <TextField, String>(criteriaRows, parameter.FieldName, value => value.TrimOrNullify()); break;

                case "datepicker": conditionValue = this.ConstructCondition <DateField, DateTime?>(criteriaRows, parameter.FieldName); break;

                case "checkbox":
                    if (parameter.Type == SearchParameterTypes.Standard)
                    {
                        conditionValue = this.ConstructCondition <CheckField, Boolean>(criteriaRows, parameter.FieldName);
                    }
                    else if (parameter.Type == SearchParameterTypes.Exclusion && this.ConstructCondition <CheckField, Boolean>(criteriaRows, parameter.FieldName))
                    {
                        conditionValue = true;
                    }
                    break;

                case "select":
                    if (parameter.CodeType != null)
                    {
                        conditionValue = this.ConstructCondition <CodeField, String>(criteriaRows, parameter.FieldName, value => value.TrimOrNullify());
                    }
                    else
                    {
                        conditionValue = this.ConstructCondition <ListField, String>(criteriaRows, parameter.FieldName, value => value.TrimOrNullify());
                    }
                    break;

                case "profile":
                    conditionValue = ConstuctProfileCondition(criteriaRows, parameter, out searchFieldName);
                    break;
                }

                if (conditionValue != null)
                {
                    if (String.IsNullOrEmpty(parameter.ConditionSql))
                    {
                        QueryConditionTypes conditionType = QueryConditionTypes.Equal;
                        switch (parameter.Condition)
                        {
                        case "EQ": conditionType = QueryConditionTypes.Equal; break;

                        case "NOT EQ": conditionType = QueryConditionTypes.NotEqual; break;

                        case "GT": conditionType = QueryConditionTypes.GreaterThan; break;

                        case "GTE": conditionType = QueryConditionTypes.GreaterThanOrEqual; break;

                        case "LT": conditionType = QueryConditionTypes.LessThan; break;

                        case "LTE": conditionType = QueryConditionTypes.LessThanOrEqual; break;

                        case "STARTS": conditionType = QueryConditionTypes.StartsWith; break;

                        case "CONTAINS": conditionType = QueryConditionTypes.Contains; break;

                        case "ENDS": conditionType = QueryConditionTypes.EndsWith; break;
                        }
                        if (conditions == null)
                        {
                            conditions = query.Where(searchFieldName, conditionType, conditionValue);
                        }
                        else
                        {
                            conditions = conditions.And(searchFieldName, conditionType, conditionValue);
                        }
                    }
                    else
                    {
                        if (conditions == null)
                        {
                            conditions = query.WhereRaw(parameter.ConditionSql.Replace("[[[VALUE]]]", "' + @value + '"), conditionValue);
                        }
                        else
                        {
                            conditions = conditions.AndRaw(parameter.ConditionSql.Replace("[[[VALUE]]]", "' + @value + '"), conditionValue);
                        }
                    }
                }
            }
            return((ISearchesRunnable)conditions ?? (ISearchesRunnable)query);
        }