Update expressionable

This commit is contained in:
sunkaixuna 2021-07-13 15:18:39 +08:00
parent 2fcd835d1e
commit 780923016a

View File

@ -359,6 +359,50 @@ namespace SqlSugar
return _exp;
}
}
public class Expressionable<T, T2, T3, T4, T5, T6, T7, T8,T9> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new()
{
Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> _exp = null;
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8,T9> And(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> exp)
{
if (_exp == null)
_exp = exp;
else
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
return this;
}
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8,T9> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> exp)
{
if (isAnd)
And(exp);
return this;
}
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8,T9> Or(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> exp)
{
if (_exp == null)
_exp = exp;
else
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
return this;
}
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8,T9> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> exp)
{
if (isOr)
Or(exp);
return this;
}
public Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> ToExpression()
{
if (_exp == null)
_exp = (it, t2, t3, t4, T5, t6, t7, t8,t9) => true;
return _exp;
}
}
public class Expressionable
{
public static Expressionable<T> Create<T>() where T : class, new()
@ -393,5 +437,9 @@ namespace SqlSugar
{
return new Expressionable<T, T2, T3, T4, T5, T6, T7,T8>();
}
public static Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9> Create<T, T2, T3, T4, T5, T6, T7, T8,T9>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new() where T7 : class, new() where T8 : class, new() where T9 : class, new()
{
return new Expressionable<T, T2, T3, T4, T5, T6, T7, T8, T9>();
}
}
}