/// <summary>
 /// 生成where命令。
 /// </summary>
 /// <param name="expression">带格式串的表达式。</param>
 /// <param name="value">值,忽略null和string.Empty。</param>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="valueFilter">值过虑器,value不为null或string.Empty时。</param>
 /// <returns></returns>
 public virtual ISelectCommandBuilder WhereIf(string expression, object value, WhereOperators @operator, WhereIfValueFilterDelegate <object> valueFilter = null)
 {
     _whereExpression?.WhereIf(expression, value, @operator, valueFilter);
     return(this);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 生成where命令。
 /// </summary>
 /// <param name="expression">带格式串的表达式。</param>
 /// <param name="value">值,忽略null和string.Empty。</param>
 /// <param name="operator">逻辑操作符。</param>
 /// <param name="valueFilter">值过虑器,value不为null或string.Empty时。</param>
 /// <returns></returns>
 public virtual IWhereExpression WhereIf(string expression, object value, WhereOperators @operator, WhereIfValueFilterDelegate <object> valueFilter = null)
 {
     if (!string.IsNullOrEmpty(expression) && value != null)
     {
         if (value is string && string.IsNullOrEmpty((string)value))
         {
             return(this);
         }
         return(Where(@operator, string.Format(expression, AddCommandParameter(valueFilter == null ? value : valueFilter(value)))));
     }
     return(this);
 }
 /// <summary>
 /// 生成where命令。
 /// </summary>
 /// <param name="expression">带格式串的表达式。</param>
 /// <param name="value">值,忽略null和string.Empty。</param>
 /// <param name="op">逻辑操作符:and、or,不区分大小写。</param>
 /// <param name="valueFilter">值过虑器,value不为null或string.Empty时。</param>
 /// <returns></returns>
 public virtual ISelectCommandBuilder WhereIf(string expression, object value, string op = "and", WhereIfValueFilterDelegate <object> valueFilter = null)
 {
     _whereExpression?.WhereIf(expression, value, op, valueFilter);
     return(this);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 生成where命令。
 /// </summary>
 /// <param name="expression">带格式串的表达式。</param>
 /// <param name="value">值,忽略null和string.Empty。</param>
 /// <param name="op">逻辑操作符:and、or,不区分大小写。</param>
 /// <param name="valueFilter">值过虑器,value不为null或string.Empty时。</param>
 /// <returns></returns>
 public virtual IWhereExpression WhereIf(string expression, string value, string op = "and", WhereIfValueFilterDelegate <string> valueFilter = null)
 {
     if (!string.IsNullOrEmpty(expression) && !string.IsNullOrEmpty(value))
     {
         return(Where(string.Format(expression, AddCommandParameter(valueFilter == null ? value : valueFilter(value))), op));
     }
     return(this);
 }