mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-09 02:44:58 +08:00
-
This commit is contained in:
@@ -31,7 +31,7 @@ namespace OrmTest.ExpressionTest
|
|||||||
{
|
{
|
||||||
var list = db.Queryable<Student, School>((st, sc) => new object[] {
|
var list = db.Queryable<Student, School>((st, sc) => new object[] {
|
||||||
JoinType.Left,st.SchoolId==sc.Id
|
JoinType.Left,st.SchoolId==sc.Id
|
||||||
}).ToList();
|
}).Where(st=>st.Id>0).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,27 +10,34 @@ namespace SqlSugar
|
|||||||
public class QueryableAccessory
|
public class QueryableAccessory
|
||||||
{
|
{
|
||||||
protected List<SugarParameter> _Pars;
|
protected List<SugarParameter> _Pars;
|
||||||
|
protected List<SugarParameter> Pars
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_Pars == null)
|
||||||
|
_Pars = new List<SugarParameter>();
|
||||||
|
return _Pars;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
protected void AddPars(object whereObj, SqlSugarClient context)
|
protected void AddPars(object whereObj, SqlSugarClient context)
|
||||||
{
|
{
|
||||||
var sqlParsArray = context.Database.GetParameters(whereObj);
|
var sqlParsArray = context.Database.GetParameters(whereObj);
|
||||||
if (_Pars == null)
|
|
||||||
_Pars = new List<SugarParameter>();
|
|
||||||
if (sqlParsArray != null)
|
if (sqlParsArray != null)
|
||||||
_Pars.AddRange(sqlParsArray);
|
this.Pars.AddRange(sqlParsArray);
|
||||||
}
|
}
|
||||||
protected void AddPars(List<SugarParameter> pars, SqlSugarClient context)
|
protected void AddPars(List<SugarParameter> pars, SqlSugarClient context)
|
||||||
{
|
{
|
||||||
if (_Pars == null)
|
if (_Pars == null)
|
||||||
_Pars = new List<SugarParameter>();
|
_Pars = new List<SugarParameter>();
|
||||||
if (pars != null)
|
_Pars.AddRange(pars);
|
||||||
_Pars.AddRange(pars);
|
|
||||||
}
|
}
|
||||||
protected void Where<T>(Expression<Func<T, bool>> expression, ResolveExpressType type, SqlSugarClient context) where T : class, new()
|
protected void Where<T>(Expression<Func<T, bool>> expression, ResolveExpressType type, SqlSugarClient context) where T : class, new()
|
||||||
{
|
{
|
||||||
ILambdaExpressions resolveExpress =InstanceFactory.GetLambdaExpressions(context.CurrentConnectionConfig);
|
ILambdaExpressions resolveExpress = InstanceFactory.GetLambdaExpressions(context.CurrentConnectionConfig);
|
||||||
resolveExpress.Resolve(expression,type);
|
resolveExpress.Resolve(expression, type);
|
||||||
_Pars.AddRange(resolveExpress.Parameters);
|
Pars.AddRange(resolveExpress.Parameters);
|
||||||
context.SqlBuilder.LambadaQueryBuilder.WhereInfos.Add(resolveExpress.Result.ToString());
|
context.SqlBuilder.LambadaQueryBuilder.WhereInfos.Add(resolveExpress.Result.GetResultString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Where<T>(string whereString, object whereObj, SqlSugarClient context) where T : class, new()
|
protected void Where<T>(string whereString, object whereObj, SqlSugarClient context) where T : class, new()
|
||||||
|
|||||||
@@ -28,7 +28,12 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public virtual ISugarQueryable<T> Where(Expression<Func<T, bool>> expression)
|
public virtual ISugarQueryable<T> Where(Expression<Func<T, bool>> expression)
|
||||||
{
|
{
|
||||||
base.Where<T>(expression, ResolveExpressType.WhereSingle, this.Context);
|
var type = ResolveExpressType.WhereSingle;
|
||||||
|
if (Context.SqlBuilder.LambadaQueryBuilder.JoinQueryInfos.IsValuable())
|
||||||
|
{
|
||||||
|
type = ResolveExpressType.WhereMultiple;
|
||||||
|
}
|
||||||
|
base.Where<T>(expression,type, this.Context);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace SqlSugar
|
|||||||
if (this.WhereInfos == null) return null;
|
if (this.WhereInfos == null) return null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return string.Join(" ", this.WhereInfos);
|
return " WHERE "+string.Join(" ", this.WhereInfos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ namespace SqlSugar
|
|||||||
public override IDataParameter[] ToIDbDataParameter(params SugarParameter[] pars)
|
public override IDataParameter[] ToIDbDataParameter(params SugarParameter[] pars)
|
||||||
{
|
{
|
||||||
if (pars == null || pars.Length == 0) return null;
|
if (pars == null || pars.Length == 0) return null;
|
||||||
IDataParameter[] reval = new IDataParameter[pars.Length];
|
SqlParameter[] reval = new SqlParameter[pars.Length];
|
||||||
|
int i = 0;
|
||||||
foreach (var par in pars)
|
foreach (var par in pars)
|
||||||
{
|
{
|
||||||
var p = new SqlParameter();
|
var p = new SqlParameter();
|
||||||
@@ -85,9 +86,10 @@ namespace SqlSugar
|
|||||||
p.Size = par.Size;
|
p.Size = par.Size;
|
||||||
p.Value = par.Value;
|
p.Value = par.Value;
|
||||||
p.DbType = par.DbType;
|
p.DbType = par.DbType;
|
||||||
reval[0] =p;
|
reval[i] =p;
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
return pars;
|
return reval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user