コード例 #1
0
 public void BeginGroupCondition(QueryConditionRelationType groupRelationType)
 {
     m_conditions.Add(new LeftBracketCondition()
     {
         GroupConditionRelationType = groupRelationType
     });
 }
コード例 #2
0
ファイル: RealTimeHelper.cs プロジェクト: sanlonezhang/ql
        private static void BuilCondition <Q>(Q filter, string dataType, List <FilterField> filterFields, DynamicQuerySqlBuilder sqlBuilder)
        {
            sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "r.BusinessDataType", DbType.String, "@BusinessDataType", QueryConditionOperatorType.Equal, dataType);
            List <string> changeTypes = new List <string>()
            {
                "A", "U"
            };

            sqlBuilder.ConditionConstructor.AddInCondition(QueryConditionRelationType.AND, "r.ChangeType", DbType.String, changeTypes);

            int index = 0;

            filterFields.ForEach(p =>
            {
                object parameterValue = Invoker.PropertyGet(filter, p.Name);
                string[] pNames       = p.ValuePath.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                string path           = string.Format("(//{0}/text())[1]", pNames.Join("/"));
                DbType dbType         = GetDbType(p.DBType);
                string field          = string.Format("r.BusinessData.value('{0}','{1}')", path, p.DBType);
                QueryConditionOperatorType operatorType = GetEnum <QueryConditionOperatorType>(p.OperatorType);
                QueryConditionRelationType relationType = GetEnum <QueryConditionRelationType>(p.RelationType);

                sqlBuilder.ConditionConstructor.AddCondition(relationType,
                                                             field, dbType, "@Parameter" + index.ToString(), operatorType, parameterValue);
                index++;
            });
        }
コード例 #3
0
 public void AddCustomCondition(QueryConditionRelationType conditionRelationType, string customQueryString)
 {
     m_conditions.Add(new CustomCondition()
     {
         ConditionRelationType = conditionRelationType,
         CustomQueryString     = customQueryString
     });
 }
コード例 #4
0
 public void AddCondition(
     QueryConditionRelationType conditionRelationType,
     string fieldName, DbType parameterDbType, string parameterName, QueryConditionOperatorType conditionOperatorType,
     object parameterValue)
 {
     AddCondition(conditionRelationType, fieldName, parameterDbType, parameterName,
                  conditionOperatorType, parameterValue, DefaultParameterValueValidationCheck);
 }
コード例 #5
0
 public void AddBetweenCondition(
     QueryConditionRelationType conditionRelationType,
     string fieldName, DbType parameterDbType, string parameterName,
     QueryConditionOperatorType leftConditionOperatorType, QueryConditionOperatorType rightConditionOperatorType,
     object leftParameterValue, object rightParameterValue)
 {
     AddBetweenCondition(conditionRelationType, fieldName, parameterDbType, parameterName,
                         leftConditionOperatorType, rightConditionOperatorType, leftParameterValue, rightParameterValue,
                         DefaultParameterValueValidationCheck);
 }
コード例 #6
0
 private void AddInOrNotInCondition(QueryConditionOperatorType operationType,
                                    QueryConditionRelationType conditionRelationType, string fieldName, DbType listValueDbType, List <Object> inValues)
 {
     if (operationType != QueryConditionOperatorType.In && operationType != QueryConditionOperatorType.NotIn)
     {
         throw new ArgumentException("Operation Type must be 'In' or 'NotIn'.");
     }
     AddCondition(conditionRelationType, fieldName, listValueDbType, null,
                  operationType, inValues, value => { return(inValues != null && inValues.Count > 0); });
 }
コード例 #7
0
 public void AddNullCheckCondition(
     QueryConditionRelationType conditionRelationType, string fieldName, QueryConditionOperatorType conditionOperatorType)
 {
     if (conditionOperatorType != QueryConditionOperatorType.IsNull &&
         conditionOperatorType != QueryConditionOperatorType.IsNotNull)
     {
         throw new ArgumentException("Parameter conditionOperatorType must be IsNull or IsNotNull in this method.");
     }
     AddCondition(conditionRelationType, fieldName, DbType.Object, null,
                  conditionOperatorType, null, value => { return(true); });
 }
コード例 #8
0
 public void AddBetweenCondition(
     QueryConditionRelationType conditionRelationType,
     string fieldName, DbType parameterDbType, string parameterName,
     QueryConditionOperatorType leftConditionOperatorType, QueryConditionOperatorType rightConditionOperatorType,
     object leftParameterValue, object rightParameterValue,
     ParameterValueValidateCheckDelegate parameterValueValidateCheckHandler)
 {
     BeginGroupCondition(conditionRelationType);
     AddCondition(QueryConditionRelationType.AND, fieldName, parameterDbType, parameterName + "_Left",
                  leftConditionOperatorType, leftParameterValue, parameterValueValidateCheckHandler);
     AddCondition(QueryConditionRelationType.AND, fieldName, parameterDbType, parameterName + "_Right",
                  rightConditionOperatorType, rightParameterValue, parameterValueValidateCheckHandler);
     EndGroupCondition();
 }
コード例 #9
0
        private void AddInOrNotInCondition <TListValueType>(QueryConditionOperatorType operationType,
                                                            QueryConditionRelationType conditionRelationType, string fieldName, DbType listValueDbType, List <TListValueType> inValues)
        {
            List <Object> convertedInValues = new List <object>();

            if (inValues != null)
            {
                foreach (TListValueType element in inValues)
                {
                    convertedInValues.Add(element);
                }
            }
            AddInOrNotInCondition(operationType, conditionRelationType, fieldName, listValueDbType, convertedInValues);
        }
コード例 #10
0
 public ConditionConstructor AddSubQueryCondition(QueryConditionRelationType conditionRelationType,
                                                  string filedName, QueryConditionOperatorType conditionOperatorType, string subQuerySQLTemplate)
 {
     if (!IsStringNullOrEmpty(subQuerySQLTemplate))
     {
         SubQueryCondition condition = new SubQueryCondition()
         {
             ConditionRelationType = conditionRelationType,
             FieldName             = filedName,
             OperatorType          = conditionOperatorType,
             SubQuerySQLTemplate   = subQuerySQLTemplate,
             SubQueryConditions    = new List <Condition>()
         };
         m_conditions.Add(condition);
         ConditionConstructor result = new ConditionConstructor(condition.SubQueryConditions);
         return(result);
     }
     return(null);
 }
コード例 #11
0
 public void AddCondition(
     QueryConditionRelationType conditionRelationType,
     string fieldName, DbType parameterDbType, string parameterName, QueryConditionOperatorType conditionOperatorType,
     object parameterValue, ParameterValueValidateCheckDelegate parameterValueValidateCheckHandler)
 {
     if (parameterValueValidateCheckHandler == null)
     {
         parameterValueValidateCheckHandler = DefaultParameterValueValidationCheck;
     }
     if (parameterValueValidateCheckHandler(parameterValue))
     {
         m_conditions.Add(new SqlCondition
         {
             ConditionRelationType = conditionRelationType,
             ParameterDbType       = parameterDbType,
             FieldName             = fieldName,
             ParameterName         = parameterName,
             OperatorType          = conditionOperatorType,
             ParameterValue        = parameterValue
         });
     }
 }
コード例 #12
0
 public void AddNotInCondition <TListValueType>(QueryConditionRelationType conditionRelationType,
                                                string fieldName, DbType listValueDbType, List <TListValueType> inValues)
 {
     AddInOrNotInCondition <TListValueType>(QueryConditionOperatorType.NotIn, conditionRelationType, fieldName, listValueDbType, inValues);
 }
コード例 #13
0
 public GroupCondition(DynamicQuerySqlBuilder builder, QueryConditionRelationType groupRelationType)
 {
     m_builder = builder;
     m_builder.ConditionConstructor.BeginGroupCondition(groupRelationType);
 }