mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-07 14:18:03 +08:00
-
This commit is contained in:
parent
bc8fad8275
commit
3ecf1beaea
Binary file not shown.
@ -16,10 +16,11 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Expression<Func<Student, bool>> exp = it => it.Name!="a";
|
string id = "1";
|
||||||
|
Expression<Func<Student, bool>> exp = it => it.Name!=id;
|
||||||
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.Single);
|
ExpressionContext expContext = new ExpressionContext(exp, ResolveExpressType.Single);
|
||||||
// var x = expContext.GetFiledName();
|
// var x = expContext.GetFiledName();
|
||||||
var xx = expContext.ToString();
|
var xx = expContext.ToSqlString();
|
||||||
|
|
||||||
|
|
||||||
var b = DateTime.Now;
|
var b = DateTime.Now;
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -11,6 +11,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public ResolveExpressType Type { get; set; }
|
public ResolveExpressType Type { get; set; }
|
||||||
public Expression Expression { get; set; }
|
public Expression Expression { get; set; }
|
||||||
|
public StringBuilder SqlWhere { get; set; }
|
||||||
public virtual string SqlParameterKeyWord
|
public virtual string SqlParameterKeyWord
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -30,12 +31,12 @@ namespace SqlSugar
|
|||||||
this.Expression = expression;
|
this.Expression = expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public string ToSqlString()
|
||||||
{
|
{
|
||||||
BaseResolve resolve = new BaseResolve(new ExpressionParameter() { Expression = this.Expression, Context = this });
|
BaseResolve resolve = new BaseResolve(new ExpressionParameter() { Expression = this.Expression, Context = this });
|
||||||
resolve.Start();
|
resolve.Start();
|
||||||
if (resolve.SqlWhere == null) return string.Empty;
|
if (this.SqlWhere == null) return string.Empty;
|
||||||
return resolve.SqlWhere.ToString();
|
return this.SqlWhere.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SugarParameter> Parameters
|
public List<SugarParameter> Parameters
|
||||||
|
@ -10,7 +10,6 @@ namespace SqlSugar
|
|||||||
protected Expression Expression { get; set; }
|
protected Expression Expression { get; set; }
|
||||||
protected Expression BaseExpression { get; set; }
|
protected Expression BaseExpression { get; set; }
|
||||||
public ExpressionContext Context { get; set; }
|
public ExpressionContext Context { get; set; }
|
||||||
public StringBuilder SqlWhere { get; set; }
|
|
||||||
public bool? IsLeft { get; set; }
|
public bool? IsLeft { get; set; }
|
||||||
public int ContentIndex { get { return this.Context.Index; } }
|
public int ContentIndex { get { return this.Context.Index; } }
|
||||||
public int Index { get; set; }
|
public int Index { get; set; }
|
||||||
|
@ -28,21 +28,21 @@ namespace SqlSugar
|
|||||||
string leftString = GetLeftString(parameter);
|
string leftString = GetLeftString(parameter);
|
||||||
string rightString = GetRightString(parameter);
|
string rightString = GetRightString(parameter);
|
||||||
string binarySql =string.Format(ExpressionConst.BinaryFormatString,leftString,operatorValue,rightString);
|
string binarySql =string.Format(ExpressionConst.BinaryFormatString,leftString,operatorValue,rightString);
|
||||||
string sqlWhereString = base.SqlWhere.ObjToString();
|
string sqlWhereString = base.Context.SqlWhere.ObjToString();
|
||||||
if (base.SqlWhere == null) {
|
if (base.Context.SqlWhere == null) {
|
||||||
base.SqlWhere = new StringBuilder();
|
base.Context.SqlWhere = new StringBuilder();
|
||||||
}
|
}
|
||||||
if (sqlWhereString.Contains(ExpressionConst.Format0))
|
if (sqlWhereString.Contains(ExpressionConst.Format0))
|
||||||
{
|
{
|
||||||
base.SqlWhere.Replace(ExpressionConst.Format0, sqlWhereString);
|
base.Context.SqlWhere.Replace(ExpressionConst.Format0, binarySql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
base.SqlWhere.Append(binarySql);
|
base.Context.SqlWhere.Append(binarySql);
|
||||||
}
|
}
|
||||||
if (sqlWhereString.Contains(ExpressionConst.Format1))
|
if (sqlWhereString.Contains(ExpressionConst.Format1))
|
||||||
{
|
{
|
||||||
base.SqlWhere.Replace(ExpressionConst.Format1, ExpressionConst.Format0);
|
base.Context.SqlWhere.Replace(ExpressionConst.Format1, ExpressionConst.Format0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ namespace SqlSugar
|
|||||||
ExpressionType = expression.GetType()
|
ExpressionType = expression.GetType()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if (isLeft == null && base.SqlWhere == null)
|
if (isLeft == null && base.Context.SqlWhere == null)
|
||||||
{
|
{
|
||||||
base.SqlWhere = new StringBuilder();
|
base.Context.SqlWhere = new StringBuilder();
|
||||||
base.SqlWhere.Append(value);
|
base.Context.SqlWhere.Append(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ namespace SqlSugar
|
|||||||
if (expression.NodeType == ExpressionType.MemberAccess)
|
if (expression.NodeType == ExpressionType.MemberAccess)
|
||||||
{
|
{
|
||||||
string appendString = "(" +((MemberExpression)expression).Member.Name + "=1)";
|
string appendString = "(" +((MemberExpression)expression).Member.Name + "=1)";
|
||||||
base.SqlWhere.Append(appendString);
|
base.Context.SqlWhere.Append(appendString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -21,10 +21,10 @@ namespace SqlSugar
|
|||||||
Value = fieldName,
|
Value = fieldName,
|
||||||
ExpressionType = expression.GetType()
|
ExpressionType = expression.GetType()
|
||||||
}));
|
}));
|
||||||
if (isLeft == null && base.SqlWhere == null)
|
if (isLeft == null && base.Context.SqlWhere == null)
|
||||||
{
|
{
|
||||||
base.SqlWhere = new StringBuilder();
|
base.Context.SqlWhere = new StringBuilder();
|
||||||
base.SqlWhere.Append(fieldName);
|
base.Context.SqlWhere.Append(fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -3,4 +3,3 @@ F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\bin\Debug\SqlSugar.pdb
|
|||||||
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\bin\Debug\Newtonsoft.Json.dll
|
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\bin\Debug\Newtonsoft.Json.dll
|
||||||
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\obj\Debug\SqlSugar.dll
|
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\obj\Debug\SqlSugar.dll
|
||||||
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\obj\Debug\SqlSugar.pdb
|
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\obj\Debug\SqlSugar.pdb
|
||||||
F:\MyOpenSource\SqlSugar4.XNew\SqlSugar\SqlSugar\obj\Debug\SqlSugar.csprojResolveAssemblyReference.cache
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user