Beispiel #1
0
 /// <summary>
 /// 添加假如为空时条件(不建议使用,建议更改数据库设计)
 /// </summary>
 /// <param name="key">要拼接的查询字段</param>
 /// <param name="replaceValue">为空时要替换的值</param>
 /// <param name="equalValue">比较的值</param>
 /// <returns></returns>
 public SqlWhereBuilder AppendIfNull(string key, string replaceValue, string equalValue)
 {
     if (key.IsNullOrEmptyWhiteSpace())
     {
         return(this);
     }
     if (replaceValue.IsNotNullAndNotEmptyWhiteSpace() && equalValue.IsNotNullAndNotEmptyWhiteSpace())
     {
         string trueReplaceValue = string.Empty;
         bool   isFormat         = false;
         if (IsStartWithSign(replaceValue))
         {
             trueReplaceValue = string.Format("{0}{1}", "{0}", Clean(replaceValue));
             isFormat         = true;
         }
         else
         {
             trueReplaceValue = replaceValue;
         }
         string trueEqualValue = string.Empty;
         if (IsStartWithSign(equalValue))
         {
             trueEqualValue = string.Format("{0}{1}", "{0}", Clean(equalValue));
             isFormat       = true;
         }
         else
         {
             trueEqualValue = equalValue;
         }
         AddWhereInfo(string.Format(" {0}={1}", SqlQueryUtil.GetIfNull(_dbType, key, trueReplaceValue), trueEqualValue), isFormat: isFormat);
     }
     return(this);
 }
Beispiel #2
0
 /// <summary>
 /// 添加假如为空时条件(不建议使用,建议更改数据库设计)
 /// </summary>
 /// <param name="key">要拼接的查询字段</param>
 /// <param name="replaceValue">为空时要替换的值</param>
 /// <param name="equalValue">比较的值</param>
 /// <returns></returns>
 public SqlWhereBuilder AppendIfNull(string key, int replaceValue, int equalValue)
 {
     if (key.IsNullOrEmptyWhiteSpace())
     {
         return(this);
     }
     else
     {
         AddWhereInfo(string.Format(" {0}={1}", SqlQueryUtil.GetIfNull(_dbType, key, replaceValue.ToString()), equalValue.ToString()), isFormat: false);
     }
     return(this);
 }