mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-16 21:19:34 +08:00
Update .net core project
This commit is contained in:
parent
feffff0fe1
commit
4b3fdef5ec
@ -8,6 +8,13 @@ namespace SqlSugar
|
||||
{
|
||||
public class ExpressionTool
|
||||
{
|
||||
public static bool IsComparisonOperatorBool(BinaryExpression binaryExp)
|
||||
{
|
||||
return binaryExp.NodeType.IsIn(ExpressionType.Equal,
|
||||
ExpressionType.GreaterThan, ExpressionType.GreaterThanOrEqual,
|
||||
ExpressionType.LessThan, ExpressionType.LessThanOrEqual);
|
||||
}
|
||||
|
||||
public static string GetOperator(ExpressionType expressiontype)
|
||||
{
|
||||
switch (expressiontype)
|
||||
|
@ -362,6 +362,15 @@ namespace SqlSugar
|
||||
{
|
||||
return "( 1 = 2 ) ";
|
||||
}
|
||||
public virtual string TrueValue()
|
||||
{
|
||||
return "1 ";
|
||||
}
|
||||
|
||||
public virtual string FalseValue()
|
||||
{
|
||||
return "0";
|
||||
}
|
||||
|
||||
public string GuidNew()
|
||||
{
|
||||
|
@ -58,6 +58,8 @@ namespace SqlSugar
|
||||
string GetSelfAndAutoFill(string shortName,bool isSingle);
|
||||
string True();
|
||||
string False();
|
||||
string TrueValue();
|
||||
string FalseValue();
|
||||
string GuidNew();
|
||||
string MergeString(params string[] strings);
|
||||
string EqualTrue(string value);
|
||||
|
@ -416,7 +416,15 @@ namespace SqlSugar
|
||||
}
|
||||
if (isRoot && parameter.BaseExpression == null && this.Context.ResolveType.IsIn(ResolveExpressType.WhereMultiple, ResolveExpressType.WhereSingle) && (parameter.CurrentExpression is ConditionalExpression) && ((parameter.CurrentExpression as ConditionalExpression).Type == UtilConstants.BoolType))
|
||||
{
|
||||
methodValue = methodValue + "=1 ";
|
||||
var isContainsTrue = MethodValueIsTrue(methodValue);
|
||||
if (isContainsTrue)
|
||||
{
|
||||
methodValue = methodValue + "=true ";
|
||||
}
|
||||
else
|
||||
{
|
||||
methodValue = methodValue + "=1 ";
|
||||
}
|
||||
}
|
||||
if (isRoot && parameter.BaseExpression == null && this.Context.ResolveType.IsIn(ResolveExpressType.WhereMultiple, ResolveExpressType.WhereSingle) && (parameter.CurrentExpression is MethodCallExpression) && ((parameter.CurrentExpression as MethodCallExpression).Method.Name.IsIn("IIF")) && (parameter.CurrentExpression as MethodCallExpression).Method.ReturnType == UtilConstants.BoolType)
|
||||
{
|
||||
@ -437,6 +445,11 @@ namespace SqlSugar
|
||||
base.AppendValue(parameter, isLeft, methodValue);
|
||||
}
|
||||
|
||||
private static bool MethodValueIsTrue(object methodValue)
|
||||
{
|
||||
return methodValue != null && methodValue.ToString().Contains("THEN true ELSE false END");
|
||||
}
|
||||
|
||||
private object packIfElse(object methodValue)
|
||||
{
|
||||
methodValue = this.Context.DbMehtods.CaseWhen(new List<KeyValuePair<string, string>>() {
|
||||
@ -485,7 +498,41 @@ namespace SqlSugar
|
||||
}
|
||||
else if (isIFFBoolBinary && !isFirst)
|
||||
{
|
||||
AppendModelByIIFBinary(parameter, model, item);
|
||||
var binaryExp = item as BinaryExpression;
|
||||
var binaryExpEqual = binaryExp != null && ExpressionTool.IsComparisonOperatorBool(binaryExp);
|
||||
if (binaryExpEqual)
|
||||
{
|
||||
var expValue = GetNewExpressionValue(item);
|
||||
expValue= this.Context.DbMehtods.IIF(new MethodCallExpressionModel()
|
||||
{
|
||||
Name = "IIF",
|
||||
Args = new List<MethodCallExpressionArgs>()
|
||||
{
|
||||
new MethodCallExpressionArgs(){
|
||||
IsMember=true,
|
||||
MemberName=expValue
|
||||
},
|
||||
new MethodCallExpressionArgs(){
|
||||
IsMember=true,
|
||||
MemberName= Context.DbMehtods.TrueValue()
|
||||
},
|
||||
new MethodCallExpressionArgs(){
|
||||
IsMember=true,
|
||||
MemberName= Context.DbMehtods.FalseValue()
|
||||
}
|
||||
}
|
||||
});
|
||||
model.Args.Add(new MethodCallExpressionArgs()
|
||||
{
|
||||
IsMember = false,
|
||||
MemberName = expValue,
|
||||
MemberValue = expValue
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
AppendModelByIIFBinary(parameter, model, item);
|
||||
}
|
||||
|
||||
}
|
||||
else if (isIFFBoolMethod && !isFirst)
|
||||
@ -522,7 +569,6 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void AppendModelByIIFMember(ExpressionParameter parameter, MethodCallExpressionModel model, Expression item)
|
||||
{
|
||||
parameter.CommonTempData = CommonTempDataType.Result;
|
||||
|
@ -133,6 +133,14 @@ namespace SqlSugar
|
||||
}
|
||||
public class PostgreSQLMethod : DefaultDbMethod, IDbMethods
|
||||
{
|
||||
public override string TrueValue()
|
||||
{
|
||||
return "true";
|
||||
}
|
||||
public override string FalseValue()
|
||||
{
|
||||
return "false";
|
||||
}
|
||||
public override string DateDiff(MethodCallExpressionModel model)
|
||||
{
|
||||
var parameter = (DateType)(Enum.Parse(typeof(DateType), model.Args[0].MemberValue.ObjToString()));
|
||||
|
@ -476,6 +476,10 @@ namespace SqlSugar
|
||||
filegrowth = 10mb
|
||||
); ";
|
||||
}
|
||||
if (databaseName.Contains("."))
|
||||
{
|
||||
databaseName = $"[{databaseName}]";
|
||||
}
|
||||
newDb.Ado.ExecuteCommand(string.Format(sql, databaseName, databaseDirectory));
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user