- 增加 IUpdate/IDelete WhereIf 方法 #466;

This commit is contained in:
28810
2020-09-02 18:29:42 +08:00
parent ea81fde340
commit 9e9891ded4
5 changed files with 235 additions and 178 deletions

View File

@ -86,7 +86,12 @@ namespace FreeSql.Internal.CommonProvider
}
public abstract List<T1> ExecuteDeleted();
public IDelete<T1> Where(Expression<Func<T1, bool>> exp) => this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp?.Body, null, _params));
public IDelete<T1> Where(Expression<Func<T1, bool>> exp) => WhereIf(true, exp);
public IDelete<T1> WhereIf(bool condition, Expression<Func<T1, bool>> exp)
{
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)
{
if (string.IsNullOrEmpty(sql)) return this;

View File

@ -519,7 +519,12 @@ namespace FreeSql.Internal.CommonProvider
return this;
}
public IUpdate<T1> Where(Expression<Func<T1, bool>> expression) => this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, expression?.Body, null, _params));
public IUpdate<T1> Where(Expression<Func<T1, bool>> exp) => WhereIf(true, exp);
public IUpdate<T1> WhereIf(bool condition, Expression<Func<T1, bool>> exp)
{
if (condition == false || exp == null) return this;
return this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp?.Body, null, _params));
}
public IUpdate<T1> Where(string sql, object parms = null)
{
if (string.IsNullOrEmpty(sql)) return this;