コード例 #1
0
        public SqlWhereBuilder AppendConditionSub(Func <SqlWhereBuilder, SqlWhereBuilder> expression, WhereLogicType type)
        {
            var tempBuilder = new SqlWhereBuilder();

            expression.Invoke(tempBuilder);
            if (tempBuilder.Conditions.Length == 0)
            {
                return(this);
            }
            if (Conditions.Length > 0)
            {
                Conditions.Append(LogicFragment(type));
            }
            Conditions.Append("(" + tempBuilder.Conditions + ")");
            SqlParameters.AddRange(tempBuilder.SqlParameters);
            return(this);
        }
コード例 #2
0
        /// <summary>
        /// 追加逻辑条件表达式
        /// </summary>
        /// <param name="conditionFormat">条件表达式</param>
        /// <param name="paramName">SqlParameter的参数名</param>
        /// <param name="paramValue">SqlParameter的参数值</param>
        /// <param name="logicType">逻辑运算符</param>
        /// <returns></returns>
        public SqlWhereBuilder AppendCondition(WhereLogicType logicType, string conditionFormat, string paramName, object paramValue)
        {
            var condition = string.Format(conditionFormat, paramName);

            if (!IsValiditeParam(paramValue))
            {
                return(this);
            }
            if (Conditions.Length == 0)
            {
                Conditions.Append(condition);
            }
            else
            {
                Conditions.Append(LogicFragment(logicType) + condition);
            }
            SqlParameters.Add(new SqlParameter(paramName, paramValue));
            return(this);
        }