Browse Source

-

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
8dba4dc66d
  1. 96
      Src/Asp.Net/SqlSugar/Abstract/ExpressionableProvider/Expressionable.cs

96
Src/Asp.Net/SqlSugar/Abstract/ExpressionableProvider/Expressionable.cs

@ -50,36 +50,36 @@ namespace SqlSugar
return _exp; return _exp;
} }
} }
public class Expressionable<T,T2> where T : class, new() where T2 : class, new() public class Expressionable<T, T2> where T : class, new() where T2 : class, new()
{ {
Expression<Func<T,T2, bool>> _exp = null; Expression<Func<T, T2, bool>> _exp = null;
public Expressionable<T,T2> And(Expression<Func<T,T2, bool>> exp) public Expressionable<T, T2> And(Expression<Func<T, T2, bool>> exp)
{ {
if (_exp == null) if (_exp == null)
_exp = exp; _exp = exp;
else else
_exp = Expression.Lambda<Func<T,T2, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); _exp = Expression.Lambda<Func<T, T2, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
return this; return this;
} }
public Expressionable<T,T2> AndIF(bool isAnd, Expression<Func<T,T2, bool>> exp) public Expressionable<T, T2> AndIF(bool isAnd, Expression<Func<T, T2, bool>> exp)
{ {
if (isAnd) if (isAnd)
And(exp); And(exp);
return this; return this;
} }
public Expressionable<T,T2> Or(Expression<Func<T,T2, bool>> exp) public Expressionable<T, T2> Or(Expression<Func<T, T2, bool>> exp)
{ {
if (_exp == null) if (_exp == null)
_exp = exp; _exp = exp;
else else
_exp = Expression.Lambda<Func<T,T2, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); _exp = Expression.Lambda<Func<T, T2, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
return this; return this;
} }
public Expressionable<T,T2> OrIF(bool isOr, Expression<Func<T,T2, bool>> exp) public Expressionable<T, T2> OrIF(bool isOr, Expression<Func<T, T2, bool>> exp)
{ {
if (isOr) if (isOr)
Or(exp); Or(exp);
@ -87,43 +87,43 @@ namespace SqlSugar
} }
public Expression<Func<T,T2, bool>> ToExpression() public Expression<Func<T, T2, bool>> ToExpression()
{ {
if (_exp == null) if (_exp == null)
_exp = (it,t2) => true; _exp = (it, t2) => true;
return _exp; return _exp;
} }
} }
public class Expressionable<T, T2,T3> where T : class, new() where T2 : class, new() where T3 : class, new() public class Expressionable<T, T2, T3> where T : class, new() where T2 : class, new() where T3 : class, new()
{ {
Expression<Func<T, T2,T3, bool>> _exp = null; Expression<Func<T, T2, T3, bool>> _exp = null;
public Expressionable<T, T2,T3> And(Expression<Func<T, T2,T3, bool>> exp) public Expressionable<T, T2, T3> And(Expression<Func<T, T2, T3, bool>> exp)
{ {
if (_exp == null) if (_exp == null)
_exp = exp; _exp = exp;
else else
_exp = Expression.Lambda<Func<T, T2,T3, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); _exp = Expression.Lambda<Func<T, T2, T3, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
return this; return this;
} }
public Expressionable<T, T2,T3> AndIF(bool isAnd, Expression<Func<T, T2,T3, bool>> exp) public Expressionable<T, T2, T3> AndIF(bool isAnd, Expression<Func<T, T2, T3, bool>> exp)
{ {
if (isAnd) if (isAnd)
And(exp); And(exp);
return this; return this;
} }
public Expressionable<T, T2,T3> Or(Expression<Func<T, T2,T3, bool>> exp) public Expressionable<T, T2, T3> Or(Expression<Func<T, T2, T3, bool>> exp)
{ {
if (_exp == null) if (_exp == null)
_exp = exp; _exp = exp;
else else
_exp = Expression.Lambda<Func<T, T2,T3, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); _exp = Expression.Lambda<Func<T, T2, T3, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
return this; return this;
} }
public Expressionable<T, T2,T3> OrIF(bool isOr, Expression<Func<T, T2,T3, bool>> exp) public Expressionable<T, T2, T3> OrIF(bool isOr, Expression<Func<T, T2, T3, bool>> exp)
{ {
if (isOr) if (isOr)
Or(exp); Or(exp);
@ -131,43 +131,43 @@ namespace SqlSugar
} }
public Expression<Func<T, T2,T3, bool>> ToExpression() public Expression<Func<T, T2, T3, bool>> ToExpression()
{ {
if (_exp == null) if (_exp == null)
_exp = (it, t2,t3) => true; _exp = (it, t2, t3) => true;
return _exp; return _exp;
} }
} }
public class Expressionable<T, T2, T3,T4> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() public class Expressionable<T, T2, T3, T4> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new()
{ {
Expression<Func<T, T2, T3,T4, bool>> _exp = null; Expression<Func<T, T2, T3, T4, bool>> _exp = null;
public Expressionable<T, T2, T3,T4> And(Expression<Func<T, T2, T3,T4, bool>> exp) public Expressionable<T, T2, T3, T4> And(Expression<Func<T, T2, T3, T4, bool>> exp)
{ {
if (_exp == null) if (_exp == null)
_exp = exp; _exp = exp;
else else
_exp = Expression.Lambda<Func<T, T2, T3,T4, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); _exp = Expression.Lambda<Func<T, T2, T3, T4, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
return this; return this;
} }
public Expressionable<T, T2, T3,T4> AndIF(bool isAnd, Expression<Func<T, T2, T3,T4, bool>> exp) public Expressionable<T, T2, T3, T4> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, bool>> exp)
{ {
if (isAnd) if (isAnd)
And(exp); And(exp);
return this; return this;
} }
public Expressionable<T, T2, T3,T4> Or(Expression<Func<T, T2, T3,T4, bool>> exp) public Expressionable<T, T2, T3, T4> Or(Expression<Func<T, T2, T3, T4, bool>> exp)
{ {
if (_exp == null) if (_exp == null)
_exp = exp; _exp = exp;
else else
_exp = Expression.Lambda<Func<T, T2, T3,T4, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); _exp = Expression.Lambda<Func<T, T2, T3, T4, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
return this; return this;
} }
public Expressionable<T, T2, T3,T4> OrIF(bool isOr, Expression<Func<T, T2, T3,T4, bool>> exp) public Expressionable<T, T2, T3, T4> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, bool>> exp)
{ {
if (isOr) if (isOr)
Or(exp); Or(exp);
@ -175,43 +175,43 @@ namespace SqlSugar
} }
public Expression<Func<T, T2, T3,T4, bool>> ToExpression() public Expression<Func<T, T2, T3, T4, bool>> ToExpression()
{ {
if (_exp == null) if (_exp == null)
_exp = (it, t2, t3,t4) => true; _exp = (it, t2, t3, t4) => true;
return _exp; return _exp;
} }
} }
public class Expressionable<T, T2, T3, T4,T5> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5: class,new() public class Expressionable<T, T2, T3, T4, T5> where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new()
{ {
Expression<Func<T, T2, T3, T4,T5, bool>> _exp = null; Expression<Func<T, T2, T3, T4, T5, bool>> _exp = null;
public Expressionable<T, T2, T3, T4,T5> And(Expression<Func<T, T2, T3, T4,T5, bool>> exp) public Expressionable<T, T2, T3, T4, T5> And(Expression<Func<T, T2, T3, T4, T5, bool>> exp)
{ {
if (_exp == null) if (_exp == null)
_exp = exp; _exp = exp;
else else
_exp = Expression.Lambda<Func<T, T2, T3, T4,T5, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters); _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, bool>>(Expression.AndAlso(_exp.Body, exp.Body), _exp.Parameters);
return this; return this;
} }
public Expressionable<T, T2, T3, T4,T5> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4,T5, bool>> exp) public Expressionable<T, T2, T3, T4, T5> AndIF(bool isAnd, Expression<Func<T, T2, T3, T4, T5, bool>> exp)
{ {
if (isAnd) if (isAnd)
And(exp); And(exp);
return this; return this;
} }
public Expressionable<T, T2, T3, T4,T5> Or(Expression<Func<T, T2, T3, T4,T5, bool>> exp) public Expressionable<T, T2, T3, T4, T5> Or(Expression<Func<T, T2, T3, T4, T5, bool>> exp)
{ {
if (_exp == null) if (_exp == null)
_exp = exp; _exp = exp;
else else
_exp = Expression.Lambda<Func<T, T2, T3, T4,T5, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters); _exp = Expression.Lambda<Func<T, T2, T3, T4, T5, bool>>(Expression.OrElse(_exp.Body, exp.Body), _exp.Parameters);
return this; return this;
} }
public Expressionable<T, T2, T3, T4,T5> OrIF(bool isOr, Expression<Func<T, T2, T3, T4,T5, bool>> exp) public Expressionable<T, T2, T3, T4, T5> OrIF(bool isOr, Expression<Func<T, T2, T3, T4, T5, bool>> exp)
{ {
if (isOr) if (isOr)
Or(exp); Or(exp);
@ -219,10 +219,10 @@ namespace SqlSugar
} }
public Expression<Func<T, T2, T3, T4,T5, bool>> ToExpression() public Expression<Func<T, T2, T3, T4, T5, bool>> ToExpression()
{ {
if (_exp == null) if (_exp == null)
_exp = (it, t2, t3, t4,T5) => true; _exp = (it, t2, t3, t4, T5) => true;
return _exp; return _exp;
} }
} }
@ -233,21 +233,21 @@ namespace SqlSugar
{ {
return new Expressionable<T>(); return new Expressionable<T>();
} }
public static Expressionable<T,T2> Create<T,T2>() where T : class, new() where T2 : class, new() public static Expressionable<T, T2> Create<T, T2>() where T : class, new() where T2 : class, new()
{ {
return new Expressionable<T,T2>(); return new Expressionable<T, T2>();
} }
public static Expressionable<T, T2,T3> Create<T, T2,T3>() where T : class, new() where T2 : class, new() where T3 : class, new() public static Expressionable<T, T2, T3> Create<T, T2, T3>() where T : class, new() where T2 : class, new() where T3 : class, new()
{ {
return new Expressionable<T, T2,T3>(); return new Expressionable<T, T2, T3>();
} }
public static Expressionable<T, T2, T3,T4> Create<T, T2, T3,T4>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4: class, new() public static Expressionable<T, T2, T3, T4> Create<T, T2, T3, T4>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new()
{ {
return new Expressionable<T, T2, T3,T4>(); return new Expressionable<T, T2, T3, T4>();
} }
public static Expressionable<T, T2, T3, T4,T5> Create<T, T2, T3, T4,T5>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5:class,new() public static Expressionable<T, T2, T3, T4, T5> Create<T, T2, T3, T4, T5>() where T : class, new() where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new()
{ {
return new Expressionable<T, T2, T3, T4,T5>(); return new Expressionable<T, T2, T3, T4, T5>();
} }
} }
} }

Loading…
Cancel
Save