mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 02:14:53 +08:00
添加 WHERE IF函数
This commit is contained in:
@@ -32,8 +32,13 @@ namespace SqlSugar
|
||||
_Pars = new List<SugarParameter>();
|
||||
_Pars.AddRange(pars);
|
||||
}
|
||||
protected void Where<T>(Expression<Func<T, bool>> expression, ResolveExpressType type,SqlSugarClient context,ISqlBuilder builder) where T : class, new()
|
||||
protected void Where(Expression expression,SqlSugarClient context,ISqlBuilder builder)
|
||||
{
|
||||
ResolveExpressType type = ResolveExpressType.WhereSingle;
|
||||
if (builder.LambadaQueryBuilder.JoinQueryInfos.IsValuable())
|
||||
{
|
||||
type = ResolveExpressType.WhereMultiple;
|
||||
}
|
||||
ILambdaExpressions resolveExpress = context.LambdaExpressions;
|
||||
resolveExpress.Resolve(expression, type);
|
||||
BasePars.AddRange(resolveExpress.Parameters);
|
||||
|
||||
@@ -56,47 +56,93 @@ namespace SqlSugar
|
||||
|
||||
public virtual ISugarQueryable<T> Where(Expression<Func<T, bool>> expression)
|
||||
{
|
||||
var type = ResolveExpressType.WhereSingle;
|
||||
if (this.SqlBuilder.LambadaQueryBuilder.JoinQueryInfos.IsValuable())
|
||||
{
|
||||
type = ResolveExpressType.WhereMultiple;
|
||||
}
|
||||
base.Where<T>(expression, type, this.Context, this.SqlBuilder);
|
||||
base.Where(expression,this.Context, this.SqlBuilder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ISugarQueryable<T> Where(string whereString, object whereObj = null)
|
||||
{
|
||||
base.Where<T>(whereString, whereObj, this.Context, this.SqlBuilder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ISugarQueryable<T> Where<T2>(string whereString, object whereObj = null) where T2 : class, new()
|
||||
{
|
||||
base.Where<T2>(whereString, whereObj, this.Context, this.SqlBuilder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ISugarQueryable<T> Where<T2>(Expression<Func<T2, bool>> expression) where T2 : class, new()
|
||||
{
|
||||
base.Where(expression, this.Context, this.SqlBuilder);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> Where<T2, T3>(Expression<Func<T2, T3, bool>> expression) where T2 : class, new() where T3 : class, new()
|
||||
{
|
||||
base.Where(expression, this.Context, this.SqlBuilder);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> Where<T2, T3, T4>(Expression<Func<T2, T3, T4, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new()
|
||||
{
|
||||
base.Where(expression, this.Context, this.SqlBuilder);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> Where<T2, T3, T4, T5>(Expression<Func<T2, T3, T4, T5, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new()
|
||||
{
|
||||
base.Where(expression, this.Context, this.SqlBuilder);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> Where<T2, T3, T4, T5, T6>(Expression<Func<T2, T3, T4, T5, T6, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new()
|
||||
{
|
||||
base.Where(expression, this.Context, this.SqlBuilder);
|
||||
return this;
|
||||
}
|
||||
public virtual ISugarQueryable<T> WhereIF(bool isWhere,Expression<Func<T, bool>> expression)
|
||||
{
|
||||
if (!isWhere) return this;
|
||||
Where<T>(expression);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> WhereIF(bool isWhere, string whereString, object whereObj = null)
|
||||
{
|
||||
if (!isWhere) return this;
|
||||
base.Where<T>(whereString, whereObj, this.Context, this.SqlBuilder);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> WhereIF<T2>(bool isWhere, string whereString, object whereObj = null) where T2 : class, new()
|
||||
{
|
||||
if (!isWhere) return this;
|
||||
base.Where<T2>(whereString, whereObj, this.Context, this.SqlBuilder);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> WhereIF<T2>(bool isWhere, Expression<Func<T2, bool>> expression) where T2 : class, new()
|
||||
{
|
||||
if (!isWhere) return this;
|
||||
this.Where(expression);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> WhereIF<T2, T3>(bool isWhere, Expression<Func<T2, T3, bool>> expression) where T2 : class, new() where T3 : class, new()
|
||||
{
|
||||
if (!isWhere) return this;
|
||||
this.Where(expression);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> WhereIF<T2, T3, T4>(bool isWhere, Expression<Func<T2, T3, T4, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new()
|
||||
{
|
||||
if (!isWhere) return this;
|
||||
this.Where(expression);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> WhereIF<T2, T3, T4, T5>(bool isWhere, Expression<Func<T2, T3, T4, T5, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new()
|
||||
{
|
||||
if (!isWhere) return this;
|
||||
this.Where(expression);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> WhereIF<T2, T3, T4, T5, T6>(bool isWhere, Expression<Func<T2, T3, T4, T5, T6, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new()
|
||||
{
|
||||
if (!isWhere) return this;
|
||||
this.Where(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ISugarQueryable<T> In(params object[] pkValues)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -24,6 +24,13 @@ namespace SqlSugar
|
||||
ISugarQueryable<T> Where<T2, T3, T4>(Expression<Func<T2, T3, T4, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new();
|
||||
ISugarQueryable<T> Where<T2, T3, T4, T5>(Expression<Func<T2, T3, T4, T5, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new();
|
||||
ISugarQueryable<T> Where<T2, T3, T4, T5, T6>(Expression<Func<T2, T3, T4, T5, T6, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new();
|
||||
ISugarQueryable<T> WhereIF(bool isWhere, Expression<Func<T, bool>> expression);
|
||||
ISugarQueryable<T> WhereIF(bool isWhere,string whereString, object whereObj = null);
|
||||
ISugarQueryable<T> WhereIF<T2>(bool isWhere, Expression<Func<T2, bool>> expression) where T2 : class, new();
|
||||
ISugarQueryable<T> WhereIF<T2, T3>(bool isWhere, Expression<Func<T2, T3, bool>> expression) where T2 : class, new() where T3 : class, new();
|
||||
ISugarQueryable<T> WhereIF<T2, T3, T4>(bool isWhere, Expression<Func<T2, T3, T4, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new();
|
||||
ISugarQueryable<T> WhereIF<T2, T3, T4, T5>(bool isWhere, Expression<Func<T2, T3, T4, T5, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new();
|
||||
ISugarQueryable<T> WhereIF<T2, T3, T4, T5, T6>(bool isWhere, Expression<Func<T2, T3, T4, T5, T6, bool>> expression) where T2 : class, new() where T3 : class, new() where T4 : class, new() where T5 : class, new() where T6 : class, new();
|
||||
ISugarQueryable<T> In(params object[] pkValues);
|
||||
|
||||
T InSingle(object pkValue);
|
||||
|
||||
Reference in New Issue
Block a user