示例#1
0
 /// <summary>
 ///  获取Where条件SQL
 /// </summary>
 public string GetWhereSql()
 {
     if (string.IsNullOrWhiteSpace(WhereBuilder.ToString().Trim()))
     {
         WhereBuilder.Append(" 1=1");
     }
     return(WhereBuilder.ToString().Trim());
 }
 /// <summary>
 /// 使用sql查询条件
 /// </summary>
 /// <param name="sqlWhere"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public ICommand <T> Where(string sqlWhere, object param = null)
 {
     WhereBuilder.Append(" AND " + sqlWhere);
     if (param != null)
     {
         Params.AddDynamicParams(param);
     }
     return(this);
 }
 /// <summary>
 /// 使用sql查询条件
 /// </summary>
 /// <param name="sqlWhere"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public QuerySet <T> Where(string sqlWhere, object param = null)
 {
     WhereBuilder.Append(" AND " + sqlWhere);
     if (param != null)
     {
         Params.AddDynamicParams(param, true);
     }
     return(this);
 }
示例#4
0
 public PagedSelectCommandBuilder Or(string value)
 => this.Chain(() =>
 {
     if (WhereBuilder.Length == 0)
     {
         throw new InvalidOperationException("There is no WHERE clause to combine the current value with");
     }
     WhereBuilder.Append(" OR ").Append(value);
 });
示例#5
0
 public PagedSelectCommandBuilder Where(string value)
 => this.Chain(() =>
 {
     if (WhereBuilder.Length > 0)
     {
         WhereBuilder.Append(" AND ");
     }
     WhereBuilder.Append(value);
 });
示例#6
0
        public QuerySet <T> Where <TWhere1, TWhere2>(Expression <Func <TWhere1, TWhere2, bool> > exp)
        {
            var sqlWhere = new WhereExpression(exp, $"Where_{Params.ParameterNames.Count()}_", SqlProvider.ProviderOption);

            WhereBuilder.Append(sqlWhere.SqlCmd);
            if (sqlWhere.Param != null)
            {
                Params.AddDynamicParams(sqlWhere.Param);
            }
            return(this);
        }