Update Core

This commit is contained in:
sunkaixuan
2017-07-04 01:00:39 +08:00
parent afe4e1bcd0
commit e28f8b0ad7
10 changed files with 172 additions and 22 deletions

View File

@@ -665,7 +665,7 @@ namespace SqlSugar
_Where(expression);
return this;
}
public ISugarQueryable<T, T2> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
public new ISugarQueryable<T, T2> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
{
if (isWhere)
_Where(expression);
@@ -677,6 +677,18 @@ namespace SqlSugar
_Where(expression);
return this;
}
public new ISugarQueryable<T, T2> Where(string whereString, object whereObj)
{
Where<T>(whereString, whereObj);
return this;
}
public new ISugarQueryable<T, T2> WhereIF(bool isWhere, string whereString, object whereObj)
{
if (!isWhere) return this;
this.Where<T>(whereString, whereObj);
return this;
}
#endregion
#region Select
@@ -802,12 +814,25 @@ namespace SqlSugar
return this;
}
public ISugarQueryable<T, T2, T3> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
public new ISugarQueryable<T, T2, T3> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
{
if (isWhere)
_Where(expression);
return this;
}
public new ISugarQueryable<T, T2,T3> Where(string whereString, object whereObj)
{
Where<T>(whereString, whereObj);
return this;
}
public new ISugarQueryable<T, T2,T3> WhereIF(bool isWhere, string whereString, object whereObj)
{
if (!isWhere) return this;
this.Where<T>(whereString, whereObj);
return this;
}
#endregion
}
@@ -837,7 +862,7 @@ namespace SqlSugar
return this;
}
public ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
public new ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
{
if (isWhere)
_Where(expression);
@@ -864,6 +889,19 @@ namespace SqlSugar
_Where(expression);
return this;
}
public new ISugarQueryable<T, T2, T3,T4> Where(string whereString, object whereObj)
{
Where<T>(whereString, whereObj);
return this;
}
public new ISugarQueryable<T, T2, T3,T4> WhereIF(bool isWhere, string whereString, object whereObj)
{
if (!isWhere) return this;
this.Where<T>(whereString, whereObj);
return this;
}
#endregion
#region Select
@@ -958,7 +996,7 @@ namespace SqlSugar
return this;
}
public ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
public new ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
{
if (isWhere)
_Where(expression);
@@ -992,6 +1030,19 @@ namespace SqlSugar
_Where(expression);
return this;
}
public new ISugarQueryable<T, T2, T3, T4,T5> Where(string whereString, object whereObj)
{
Where<T>(whereString, whereObj);
return this;
}
public new ISugarQueryable<T, T2, T3, T4,T5> WhereIF(bool isWhere, string whereString, object whereObj)
{
if (!isWhere) return this;
this.Where<T>(whereString, whereObj);
return this;
}
#endregion
#region Select
@@ -1105,7 +1156,7 @@ namespace SqlSugar
return this;
}
public ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
public new ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, bool>> expression)
{
if (isWhere)
_Where(expression);
@@ -1146,6 +1197,19 @@ namespace SqlSugar
_Where(expression);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5,T6> Where(string whereString, object whereObj)
{
Where<T>(whereString, whereObj);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5,T6> WhereIF(bool isWhere, string whereString, object whereObj)
{
if (!isWhere) return this;
this.Where<T>(whereString, whereObj);
return this;
}
#endregion
#region Select
@@ -1326,6 +1390,19 @@ namespace SqlSugar
_Where(expression);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> Where(string whereString, object whereObj)
{
Where<T>(whereString, whereObj);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> WhereIF(bool isWhere, string whereString, object whereObj)
{
if (!isWhere) return this;
this.Where<T>(whereString, whereObj);
return this;
}
#endregion
#region Select
@@ -1533,6 +1610,19 @@ namespace SqlSugar
_Where(expression);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8> Where(string whereString, object whereObj)
{
Where<T>(whereString, whereObj);
return this;
}
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8> WhereIF(bool isWhere, string whereString, object whereObj)
{
if (!isWhere) return this;
this.Where<T>(whereString, whereObj);
return this;
}
#endregion
#region Select

View File

@@ -46,7 +46,17 @@ namespace SqlSugar
return null;
}
}
public static bool IsLogicOperator(string operatorValue)
{
return operatorValue=="&&"|| operatorValue=="||";
}
public static bool IsComparisonOperator(BinaryExpression expression)
{
return expression.NodeType != ExpressionType.And &&
expression.NodeType != ExpressionType.AndAlso &&
expression.NodeType != ExpressionType.Or &&
expression.NodeType != ExpressionType.OrElse;
}
public static object GetMemberValue(MemberInfo member, Expression expression)
{
var memberInfos = new Stack<MemberInfo>();

View File

@@ -247,5 +247,12 @@ namespace SqlSugar
var parameter = model.Args[0];
return string.Format("COUNT({0})", parameter.MemberName);
}
public virtual string MappingColumn(MethodCallExpressionModel model)
{
var parameter = model.Args[0];
var parameter1 = model.Args[1];
return string.Format("{0}", parameter1.MemberValue);
}
}
}

View File

@@ -45,5 +45,6 @@ namespace SqlSugar
string AggregateMin(MethodCallExpressionModel model);
string AggregateMax(MethodCallExpressionModel model);
string AggregateCount(MethodCallExpressionModel model);
string MappingColumn(MethodCallExpressionModel model);
}
}

View File

@@ -83,5 +83,6 @@ namespace SqlSugar
public static TResult AggregateMin<TResult>(TResult thisValue) { throw new NotSupportedException("This method is not supported by the current parameter"); }
public static TResult AggregateMax<TResult>(TResult thisValue) { throw new NotSupportedException("This method is not supported by the current parameter"); }
public static TResult AggregateCount<TResult>(TResult thisValue) { throw new NotSupportedException("This method is not supported by the current parameter"); }
public static TResult MappingColumn<TResult>(TResult oldColumnName,string newColumnName) { throw new NotSupportedException("This method is not supported by the current parameter"); }
}
}

View File

@@ -18,13 +18,9 @@ namespace SqlSugar
else
{
var expression = this.Expression as BinaryExpression;
var operatorValue =parameter.OperatorValue=ExpressionTool.GetOperator(expression.NodeType);
var isEqual = expression.NodeType==ExpressionType.Equal;
var isComparisonOperator =
expression.NodeType != ExpressionType.And &&
expression.NodeType != ExpressionType.AndAlso &&
expression.NodeType != ExpressionType.Or &&
expression.NodeType != ExpressionType.OrElse;
var operatorValue = parameter.OperatorValue = ExpressionTool.GetOperator(expression.NodeType);
var isEqual = expression.NodeType == ExpressionType.Equal;
var isComparisonOperator =ExpressionTool.IsComparisonOperator(expression);
base.ExactExpression = expression;
var leftExpression = expression.Left;
var rightExpression = expression.Right;
@@ -40,8 +36,9 @@ namespace SqlSugar
base.Context.Result.Append(ExpressionConst.Format3);
base.Context.Result.Append(ExpressionConst.Format0);
}
else {
base.Context.Result.Replace(ExpressionConst.Format0,ExpressionConst.Format3+ ExpressionConst.Format0);
else
{
base.Context.Result.Replace(ExpressionConst.Format0, ExpressionConst.Format3 + ExpressionConst.Format0);
}
parameter.LeftExpression = leftExpression;
parameter.RightExpression = rightExpression;
@@ -54,16 +51,17 @@ namespace SqlSugar
base.IsLeft = null;
if (lsbs && parameter.ValueIsNull)
{
base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, isEqual?"IS":"IS NOT");
base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, isEqual ? "IS" : "IS NOT");
}
else {
else
{
base.Context.Result.Replace(ExpressionConst.Format1 + parameter.Index, operatorValue);
base.Context.Result.Replace(ExpressionConst.Format1 +(parameter.Index+1), operatorValue);
base.Context.Result.Replace(ExpressionConst.Format1 + (parameter.Index + 1), operatorValue);
}
base.Context.Result.Append(ExpressionConst.Format4);
if (parameter.BaseExpression is BinaryExpression && parameter.IsLeft == true)
{
base.Context.Result.Append(" "+ExpressionConst.Format1 + parameter.BaseParameter.Index+" ");
base.Context.Result.Append(" " + ExpressionConst.Format1 + parameter.BaseParameter.Index + " ");
}
}
}

View File

@@ -61,8 +61,11 @@ namespace SqlSugar
else
{
fieldName = getSingleName(parameter, expression, isLeft);
if (expression.Type == PubConst.BoolType&&baseParameter.OperatorValue.IsNullOrEmpty()) {
fieldName= "( "+fieldName+"=1 )";
}
fieldName = AppendMember(parameter, isLeft, fieldName);
}
}
break;
case ResolveExpressType.WhereMultiple:
if (isSetTempData)

View File

@@ -234,6 +234,12 @@ namespace SqlSugar
return this.Context.DbMehtods.AggregateMax(model);
case "AggregateCount":
return this.Context.DbMehtods.AggregateCount(model);
case "MappingColumn":
var mappingColumnResult = this.Context.DbMehtods.MappingColumn(model);
var isValid= model.Args[0].IsMember&&model.Args[1].IsMember==false;
Check.Exception(!isValid, "SqlFunc.MappingColumn parameters error, The property name on the left, string value on the right");
this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[1].MemberName.ObjToString());
return mappingColumnResult;
default:
break;
}

View File

@@ -32,7 +32,20 @@ namespace SqlSugar
{
Append(parameter, nodeType);
}
else if (isMember || isConst)
else if (isMember)
{
var isComparisonOperator = ExpressionTool.IsLogicOperator(baseParameter.OperatorValue)||baseParameter.OperatorValue.IsNullOrEmpty();
var memberExpression = (base.Expression as MemberExpression);
if (memberExpression.Type== PubConst.BoolType&& isComparisonOperator)
{
Append(parameter, nodeType);
}
else
{
Result(parameter, nodeType);
}
}
else if (isConst)
{
Result(parameter, nodeType);
}

View File

@@ -99,6 +99,9 @@ namespace SqlSugar
new ISugarQueryable<T, T2> WhereIF(bool isWhere,Expression<Func<T, bool>> expression);
ISugarQueryable<T, T2> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression);
new ISugarQueryable<T,T2> Where(string whereString, object whereObj = null);
new ISugarQueryable<T,T2> WhereIF(bool isWhere, string whereString, object whereObj = null);
#endregion
#region Select
@@ -125,6 +128,9 @@ namespace SqlSugar
new ISugarQueryable<T, T2, T3> WhereIF(bool isWhere, Expression<Func<T, bool>> expression);
ISugarQueryable<T, T2, T3> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression);
ISugarQueryable<T, T2, T3> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression);
new ISugarQueryable<T, T2,T3> Where(string whereString, object whereObj = null);
new ISugarQueryable<T, T2,T3> WhereIF(bool isWhere, string whereString, object whereObj = null);
#endregion
#region Select
@@ -156,6 +162,9 @@ namespace SqlSugar
ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression);
ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression);
ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression);
new ISugarQueryable<T, T2,T3,T4> Where(string whereString, object whereObj = null);
new ISugarQueryable<T, T2, T3, T4> WhereIF(bool isWhere, string whereString, object whereObj = null);
#endregion
#region Select
@@ -193,6 +202,9 @@ namespace SqlSugar
ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression);
new ISugarQueryable<T, T2, T3, T4,T5> Where(string whereString, object whereObj = null);
new ISugarQueryable<T, T2, T3, T4,T5> WhereIF(bool isWhere, string whereString, object whereObj = null);
#endregion
#region Select
@@ -234,6 +246,9 @@ namespace SqlSugar
ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression);
new ISugarQueryable<T, T2, T3, T4, T5 ,T6> Where(string whereString, object whereObj = null);
new ISugarQueryable<T, T2, T3, T4, T5,T6> WhereIF(bool isWhere, string whereString, object whereObj = null);
#endregion
#region Select
@@ -273,13 +288,16 @@ namespace SqlSugar
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> Where(Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, bool>> expression);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, T3, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression);
new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> Where(string whereString, object whereObj = null);
new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> WhereIF(bool isWhere, string whereString, object whereObj = null);
#endregion
#region Select
@@ -331,6 +349,9 @@ namespace SqlSugar
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, bool>> expression);
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> WhereIF(bool isWhere, Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, bool>> expression);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8> Where(string whereString, object whereObj = null);
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8> WhereIF(bool isWhere, string whereString, object whereObj = null);
#endregion
#region Select