- 完善 IDelete WhereIf(bool, sql) 方法;

This commit is contained in:
2881099
2020-12-07 20:02:57 +08:00
parent 671fb09146
commit ff1354d46c
3 changed files with 22 additions and 185 deletions

View File

@ -98,9 +98,10 @@ namespace FreeSql.Internal.CommonProvider
if (condition == false || exp == null) return this;
return this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp?.Body, null, _params));
}
public IDelete<T1> Where(string sql, object parms = null)
public IDelete<T1> Where(string sql, object parms = null) => WhereIf(true, sql, parms);
public IDelete<T1> WhereIf(bool condition, string sql, object parms = null)
{
if (string.IsNullOrEmpty(sql)) return this;
if (condition == false || string.IsNullOrEmpty(sql)) return this;
if (++_whereTimes > 1) _where.Append(" AND ");
_where.Append('(').Append(sql).Append(')');
if (parms != null) _params.AddRange(_commonUtils.GetDbParamtersByObject(sql, parms));