mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 20:38:16 +08:00
This commit is contained in:
@ -24,7 +24,13 @@ public static class FreeSqlGlobalExpressionCallExtensions
|
||||
{
|
||||
if (expContext.IsValueCreated == false || expContext.Value == null || expContext.Value.ParsedContent == null)
|
||||
return that >= between && that <= and;
|
||||
expContext.Value.Result = $"{expContext.Value.ParsedContent["that"]} between {expContext.Value.ParsedContent["between"]} and {expContext.Value.ParsedContent["and"]}";
|
||||
var time1 = expContext.Value.RawExpression["between"].IsParameter() == false ?
|
||||
expContext.Value.FormatSql(Expression.Lambda(expContext.Value.RawExpression["between"]).Compile().DynamicInvoke()) :
|
||||
expContext.Value.ParsedContent["between"];
|
||||
var time2 = expContext.Value.RawExpression["and"].IsParameter() == false ?
|
||||
expContext.Value.FormatSql(Expression.Lambda(expContext.Value.RawExpression["and"]).Compile().DynamicInvoke()) :
|
||||
expContext.Value.ParsedContent["and"];
|
||||
expContext.Value.Result = $"{expContext.Value.ParsedContent["that"]} between {time1} and {time2}";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -41,7 +47,13 @@ public static class FreeSqlGlobalExpressionCallExtensions
|
||||
{
|
||||
if (expContext.IsValueCreated == false || expContext.Value == null || expContext.Value.ParsedContent == null)
|
||||
return that >= start && that < end;
|
||||
expContext.Value.Result = $"{expContext.Value.ParsedContent["that"]} >= {expContext.Value.ParsedContent["start"]} and {expContext.Value.ParsedContent["that"]} < {expContext.Value.ParsedContent["end"]}";
|
||||
var time1 = expContext.Value.RawExpression["start"].IsParameter() == false ?
|
||||
expContext.Value.FormatSql(Expression.Lambda(expContext.Value.RawExpression["start"]).Compile().DynamicInvoke()) :
|
||||
expContext.Value.ParsedContent["start"];
|
||||
var time2 = expContext.Value.RawExpression["end"].IsParameter() == false ?
|
||||
expContext.Value.FormatSql(Expression.Lambda(expContext.Value.RawExpression["end"]).Compile().DynamicInvoke()) :
|
||||
expContext.Value.ParsedContent["end"];
|
||||
expContext.Value.Result = $"{expContext.Value.ParsedContent["that"]} >= {time1} and {expContext.Value.ParsedContent["that"]} < {time2}";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>false</DelaySign>
|
||||
<Version>3.2.698-preview20230629</Version>
|
||||
<Version>3.2.698</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
12653
FreeSql/FreeSql.xml
12653
FreeSql/FreeSql.xml
File diff suppressed because it is too large
Load Diff
@ -843,7 +843,10 @@ namespace FreeSql.Internal
|
||||
var isRightMapType = false;
|
||||
if (isLeftMapType) oldMapType = tsc.SetMapTypeReturnOld(leftMapColumn.Attribute.MapType);
|
||||
|
||||
var right = ExpressionLambdaToSql(rightExp, tsc);
|
||||
var right = (leftMapColumn != null &&
|
||||
(leftMapColumn.Table.AsTableColumn == leftMapColumn && rightExp.IsParameter() == false)) ? //自动分表
|
||||
formatSql(Expression.Lambda(rightExp).Compile().DynamicInvoke(), leftMapColumn.Attribute.MapType, leftMapColumn, tsc.dbParams) :
|
||||
ExpressionLambdaToSql(rightExp, tsc);
|
||||
if (right != "NULL" && isLeftMapType &&
|
||||
//判断参数化后的bug
|
||||
!(right.Contains('@') || right.Contains('?') || right.Contains(':')) &&
|
||||
@ -866,7 +869,10 @@ namespace FreeSql.Internal
|
||||
if (isRightMapType)
|
||||
{
|
||||
oldMapType = tsc.SetMapTypeReturnOld(rightMapColumn.Attribute.MapType);
|
||||
left = ExpressionLambdaToSql(leftExp, tsc);
|
||||
left = (rightMapColumn != null &&
|
||||
(rightMapColumn.Table.AsTableColumn == rightMapColumn && leftExp.IsParameter() == false)) ? //自动分表
|
||||
formatSql(Expression.Lambda(leftExp).Compile().DynamicInvoke(), rightMapColumn.Attribute.MapType, rightMapColumn, tsc.dbParams) :
|
||||
ExpressionLambdaToSql(leftExp, tsc);
|
||||
if (left != "NULL" && isRightMapType &&
|
||||
//判断参数化后的bug
|
||||
!(left.Contains('@') || left.Contains('?') || left.Contains(':')) &&
|
||||
@ -1018,8 +1024,6 @@ namespace FreeSql.Internal
|
||||
return conditionalSql;
|
||||
}
|
||||
case ExpressionType.Call:
|
||||
//提前直接解析 内存表达式
|
||||
if (exp.IsParameter() == false) return formatSql(Expression.Lambda(exp).Compile().DynamicInvoke(), tsc.mapType, tsc.mapColumnTmp, tsc.dbParams);
|
||||
tsc.mapType = null;
|
||||
var exp3 = exp as MethodCallExpression;
|
||||
if (exp3.Object == null && (
|
||||
@ -1701,6 +1705,7 @@ namespace FreeSql.Internal
|
||||
}
|
||||
other3Exp = ExpressionLambdaToSqlOther(exp3, tsc);
|
||||
if (string.IsNullOrEmpty(other3Exp) == false) return other3Exp;
|
||||
if (exp3.IsParameter() == false) return formatSql(Expression.Lambda(exp3).Compile().DynamicInvoke(), tsc.mapType, tsc.mapColumnTmp, tsc.dbParams);
|
||||
if (exp3.Method.DeclaringType == typeof(Enumerable)) throw new Exception(CoreStrings.Not_Implemented_Expression_UseAsSelect(exp3, exp3.Method.Name, (exp3.Arguments.Count > 1 ? "..." : "")));
|
||||
throw new Exception(CoreStrings.Not_Implemented_Expression(exp3));
|
||||
case ExpressionType.Parameter:
|
||||
|
Reference in New Issue
Block a user