Browse Source

-

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
c0ff7b1c11
  1. 6
      SqlSugar/ExpressionsToSql/ExpressionConst.cs
  2. 2
      SqlSugar/ExpressionsToSql/ExpressionTool.cs
  3. 12
      SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs
  4. 2
      SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs
  5. 4
      SqlSugar/SqlSugar.csproj

6
SqlSugar/ExpressionsToSql/ExpConst.cs → SqlSugar/ExpressionsToSql/ExpressionConst.cs

@ -5,7 +5,7 @@ using System.Text;
namespace SqlSugar
{
internal class ExpConst
internal class ExpressionConst
{
public const string BinaryExpressionInfoListKey = "BinaryExpressionInfoListKey";
public const string BinaryFormatString = " ( {0} {1} {2} ) ";
@ -26,7 +26,7 @@ namespace SqlSugar
{
get
{
return ExpConst.GetThrowMessage("拉姆达解析出错:不支持{0}此种运算符查找!",
return ExpressionConst.GetThrowMessage("拉姆达解析出错:不支持{0}此种运算符查找!",
"Lambda parsing error: {0} does not support the operator to find!");
}
}
@ -34,7 +34,7 @@ namespace SqlSugar
{
get
{
return ExpConst.GetThrowMessage("Expression format error, correct format: it=>it.fieldName",
return ExpressionConst.GetThrowMessage("Expression format error, correct format: it=>it.fieldName",
"表达示格式错误,正确格式: it=>it.fieldName");
}
}

2
SqlSugar/ExpressionsToSql/ExpTool.cs → SqlSugar/ExpressionsToSql/ExpressionTool.cs

@ -5,7 +5,7 @@ using System.Linq.Expressions;
using System.Text;
namespace SqlSugar
{
public class ExpTool
public class ExpressionTool
{
public static string GetOperator(ExpressionType expressiontype)
{

12
SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs

@ -11,7 +11,7 @@ namespace SqlSugar
{
parameter.BinaryExpressionInfoList =new List<KeyValuePair<string, BinaryExpressionInfo>>();
var expression = this.Expression as BinaryExpression;
var operatorValue = ExpTool.GetOperator(expression.NodeType);
var operatorValue = ExpressionTool.GetOperator(expression.NodeType);
var isComparisonOperator =
expression.NodeType != ExpressionType.And &&
expression.NodeType != ExpressionType.AndAlso &&
@ -27,22 +27,22 @@ namespace SqlSugar
base.IsLeft = null;
string leftString = GetLeftString(parameter);
string rightString = GetRightString(parameter);
string binarySql =string.Format(ExpConst.BinaryFormatString,leftString,operatorValue,rightString);
string binarySql =string.Format(ExpressionConst.BinaryFormatString,leftString,operatorValue,rightString);
string sqlWhereString = base.SqlWhere.ToString();
if (base.SqlWhere == null) {
base.SqlWhere = new StringBuilder();
}
if (sqlWhereString.Contains(ExpConst.Format0))
if (sqlWhereString.Contains(ExpressionConst.Format0))
{
base.SqlWhere.Replace(ExpConst.Format0, sqlWhereString);
base.SqlWhere.Replace(ExpressionConst.Format0, sqlWhereString);
}
else
{
base.SqlWhere.Append(binarySql);
}
if (sqlWhereString.Contains(ExpConst.Format1))
if (sqlWhereString.Contains(ExpressionConst.Format1))
{
base.SqlWhere.Replace(ExpConst.Format1, ExpConst.Format0);
base.SqlWhere.Replace(ExpressionConst.Format1, ExpressionConst.Format0);
}
}

2
SqlSugar/ExpressionsToSql/ResolveItems/MemberExpressionResolve.cs

@ -14,7 +14,7 @@ namespace SqlSugar
var isSingle = parameter.Context.IsSingle;
string fieldName = string.Empty;
fieldName = isSingle ? expression.Member.Name : expression.Member.ToString();
parameter.BaseParameter.BinaryExpressionInfoList.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
parameter.BaseParameter.BinaryExpressionInfoList.Add(new KeyValuePair<string, BinaryExpressionInfo>(ExpressionConst.BinaryExpressionInfoListKey, new BinaryExpressionInfo()
{
IsLeft = Convert.ToBoolean(IsLeft),
Value = fieldName,

4
SqlSugar/SqlSugar.csproj

@ -109,7 +109,7 @@
<Compile Include="Enum\JoinType.cs" />
<Compile Include="Enum\OrderByType.cs" />
<Compile Include="ExpressionsToSql\ResolveExpressType.cs" />
<Compile Include="ExpressionsToSql\ExpConst.cs" />
<Compile Include="ExpressionsToSql\ExpressionConst.cs" />
<Compile Include="ExpressionsToSql\ResolveItems\BaseResolve.cs" />
<Compile Include="ExpressionsToSql\ResolveItems\BinaryExpressionResolve.cs" />
<Compile Include="ExpressionsToSql\ResolveItems\BlockExpressionResolve.cs" />
@ -121,7 +121,7 @@
<Compile Include="ExpressionsToSql\ResolveItems\UnaryExpressionResolve.cs" />
<Compile Include="ExpressionsToSql\ExpResolveAccessory.cs" />
<Compile Include="ExpressionsToSql\ExpressionContext.cs" />
<Compile Include="ExpressionsToSql\ExpTool.cs" />
<Compile Include="ExpressionsToSql\ExpressionTool.cs" />
<Compile Include="InstanceFactory.cs" />
<Compile Include="Interface\ICodeFirst.cs" />
<Compile Include="Interface\IDb.cs" />

Loading…
Cancel
Save