mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
Update Expressionable
This commit is contained in:
@@ -271,6 +271,94 @@ namespace SqlSugar
|
|||||||
return _exp;
|
return _exp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class Expressionable<T, T2, T3, T4, T5, T6,T7> 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()
|
||||||
|
{
|
||||||
|
Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> _exp = null;
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6,T7> And(Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6,T7, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6,T7> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isAnd)
|
||||||
|
And(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6,T7> Or(Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6,T7, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6,T7> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isOr)
|
||||||
|
Or(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Expression<Func<T, T2, T3, T4, T5, T6,T7, bool>> ToExpression()
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = (it, t2, t3, t4, T5, t6,t7) => true;
|
||||||
|
return _exp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class Expressionable<T, T2, T3, T4, T5, T6, T7 , T8> 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()
|
||||||
|
{
|
||||||
|
Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> _exp = null;
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6, T7,T8> And(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6, T7,T8> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isAnd)
|
||||||
|
And(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6, T7, T8> Or(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> exp)
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = exp;
|
||||||
|
else
|
||||||
|
_exp = Expression.Lambda<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Expressionable<T, T2, T3, T4, T5, T6, T7,T8> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> exp)
|
||||||
|
{
|
||||||
|
if (isOr)
|
||||||
|
Or(exp);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, bool>> ToExpression()
|
||||||
|
{
|
||||||
|
if (_exp == null)
|
||||||
|
_exp = (it, t2, t3, t4, T5, t6, t7,t8) => true;
|
||||||
|
return _exp;
|
||||||
|
}
|
||||||
|
}
|
||||||
public class Expressionable
|
public class Expressionable
|
||||||
{
|
{
|
||||||
public static Expressionable<T> Create<T>() where T : class, new()
|
public static Expressionable<T> Create<T>() where T : class, new()
|
||||||
@@ -297,5 +385,13 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return new Expressionable<T, T2, T3, T4, T5, T6>();
|
return new Expressionable<T, T2, T3, T4, T5, T6>();
|
||||||
}
|
}
|
||||||
|
public static Expressionable<T, T2, T3, T4, T5, T6,T7> Create<T, T2, T3, T4, T5, T6,T7>() 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()
|
||||||
|
{
|
||||||
|
return new Expressionable<T, T2, T3, T4, T5, T6,T7>();
|
||||||
|
}
|
||||||
|
public static Expressionable<T, T2, T3, T4, T5, T6, T7,T8> Create<T, T2, T3, T4, T5, T6, T7,T8>() 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()
|
||||||
|
{
|
||||||
|
return new Expressionable<T, T2, T3, T4, T5, T6, T7,T8>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user