修复 ISelect2 以上 WhereIf 条件作用反了 bug

This commit is contained in:
28810
2019-04-18 13:54:11 +08:00
parent 8d266a556e
commit acc1754e2e
12 changed files with 43 additions and 29 deletions

View File

@ -147,8 +147,7 @@ namespace FreeSql.Internal.CommonProvider {
}
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp) {
if (condition) return this.Where(null);
if (exp == null) return this.Where(null);
if (condition == false || exp == null) return this.Where(null);
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
}

View File

@ -221,8 +221,7 @@ namespace FreeSql.Internal.CommonProvider {
public ISelect<T1> WhereDynamic(object dywhere) => this.Where(_commonUtils.WhereObject(_tables.First().Table, $"{_tables.First().Alias}.", dywhere));
public ISelect<T1> WhereIf(bool condition, Expression<Func<T1, bool>> exp) {
if (condition == false) return this;
if (exp == null) return this;
if (condition == false || exp == null) return this;
_tables[0].Parameter = exp.Parameters[0];
return this.InternalWhere(exp?.Body);
}

View File

@ -131,10 +131,9 @@ namespace FreeSql.Internal.CommonProvider {
}
ISelect<T1, T2> ISelect<T1, T2>.WhereIf(bool condition, Expression<Func<T1, T2, bool>> exp) {
if (condition) return this.Where(null);
if (exp == null) return this.Where(null);
if (condition == false || exp == null) return this;
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
}
bool ISelect<T1, T2>.Any(Expression<Func<T1, T2, bool>> exp) {

View File

@ -133,10 +133,9 @@ namespace FreeSql.Internal.CommonProvider {
}
ISelect<T1, T2, T3> ISelect<T1, T2, T3>.WhereIf(bool condition, Expression<Func<T1, T2, T3, bool>> exp) {
if (condition) return this.Where(null);
if (exp == null) return this.Where(null);
if (condition == false || exp == null) return this;
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
}
bool ISelect<T1, T2, T3>.Any(Expression<Func<T1, T2, T3, bool>> exp) {

View File

@ -135,10 +135,9 @@ namespace FreeSql.Internal.CommonProvider {
}
ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, bool>> exp) {
if (condition) return this.Where(null);
if (exp == null) return this.Where(null);
if (condition == false || exp == null) return this;
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
}
bool ISelect<T1, T2, T3, T4>.Any(Expression<Func<T1, T2, T3, T4, bool>> exp) {

View File

@ -137,10 +137,9 @@ namespace FreeSql.Internal.CommonProvider {
}
ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, bool>> exp) {
if (condition) return this.Where(null);
if (exp == null) return this.Where(null);
if (condition == false || exp == null) return this;
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
}
bool ISelect<T1, T2, T3, T4, T5>.Any(Expression<Func<T1, T2, T3, T4, T5, bool>> exp) {

View File

@ -139,10 +139,9 @@ namespace FreeSql.Internal.CommonProvider {
}
ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp) {
if (condition) return this.Where(null);
if (exp == null) return this.Where(null);
if (condition == false || exp == null) return this;
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
}
bool ISelect<T1, T2, T3, T4, T5, T6>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp) {

View File

@ -141,10 +141,9 @@ namespace FreeSql.Internal.CommonProvider {
}
ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp) {
if (condition) return this.Where(null);
if (exp == null) return this.Where(null);
if (condition == false || exp == null) return this;
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
}
bool ISelect<T1, T2, T3, T4, T5, T6, T7>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp) {

View File

@ -143,10 +143,9 @@ namespace FreeSql.Internal.CommonProvider {
}
ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp) {
if (condition) return this.Where(null);
if (exp == null) return this.Where(null);
if (condition == false || exp == null) return this;
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
}
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp) {

View File

@ -145,10 +145,9 @@ namespace FreeSql.Internal.CommonProvider {
}
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp) {
if (condition) return this.Where(null);
if (exp == null) return this.Where(null);
if (condition == false || exp == null) return this;
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null)) : this;
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null));
}
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp) {