/// <summary>
        /// 创建新的Sql条件语句集合
        /// </summary>
        /// <param name="concatType">连接类型</param>
        /// <param name="conditions">查询语句集合</param>
        /// <returns>Sql条件语句集合</returns>
        public static SqlConditionList CreateList(SqlWhereConcatType concatType, params ISqlCondition[] conditions)
        {
            SqlConditionList list = new SqlConditionList(concatType);

            if (conditions != null)
            {
                for (Int32 i = 0; i < conditions.Length; i++)
                {
                    list.Add(conditions[i]);
                }
            }

            return(list);
        }
Beispiel #2
0
        /// <summary>
        /// 创建新的Sql条件语句集合
        /// </summary>
        /// <param name="cmd">Sql语句</param>
        /// <param name="concatType">连接类型</param>
        /// <param name="conditions">条件语句集合</param>
        /// <returns>Sql条件语句集合</returns>
        internal static SqlConditionList InternalCreate(AbstractSqlCommandWithWhere cmd, SqlWhereConcatType concatType, IEnumerable <ISqlCondition> conditions)
        {
            SqlConditionList list = new SqlConditionList(cmd, concatType);

            if (conditions != null)
            {
                foreach (ISqlCondition condition in conditions)
                {
                    list.Add(condition);
                }
            }

            return(list);
        }
        /// <summary>
        /// 两个Sql条件语句执行或操作
        /// </summary>
        /// <param name="condition1">条件1</param>
        /// <param name="condition2">条件2</param>
        /// <returns>条件列表</returns>
        public static AbstractSqlCondition operator |(AbstractSqlCondition condition1, AbstractSqlCondition condition2)
        {
            if (condition1 == null && condition2 == null)
            {
                return(null);
            }
            else if (condition1 != null && condition2 == null)
            {
                return(condition1);
            }
            else if (condition1 == null && condition2 != null)
            {
                return(condition2);
            }

            if (condition1.ConditionType == SqlConditionType.ConditionList)
            {
                SqlConditionList list = condition1 as SqlConditionList;

                if (list.ConcatType == SqlWhereConcatType.Or)
                {
                    list.Add(condition2);

                    return(list);
                }
            }

            if (condition2.ConditionType == SqlConditionType.ConditionList)
            {
                SqlConditionList list = condition2 as SqlConditionList;

                if (list.ConcatType == SqlWhereConcatType.Or)
                {
                    list.Insert(0, condition1);

                    return(list);
                }
            }

            return(condition1._baseCommand.ConditionBuilder.Or(condition1, condition2));
        }