Skip to content

Commit

Permalink
- 修复 .In(..) + MapType 无效的问题;
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Dec 3, 2024
1 parent 12d377c commit b0eb654
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 109 deletions.
232 changes: 123 additions & 109 deletions FreeSql/FreeSql.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions FreeSql/Internal/CommonExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,20 @@ public string ExpressionLambdaToSql(Expression exp, ExpTSC tsc)
var exp3 = exp as MethodCallExpression;
if (exp3.IsExpressionCall())
{
//SqlExt.In 替换成 Array.Contains 解析,可避免 MapType 问题
if (exp3.Method.Name == "In" && exp3.Method.DeclaringType == typeof(FreeSqlGlobalExpressionCallExtensions))
{
var exp3MethodGenericType = exp3.Method.GetGenericArguments().FirstOrDefault();
if (exp3MethodGenericType != null)
{
var exp3ContainsMethod = Select0Provider.GetMethodEnumerable("Contains").MakeGenericMethod(exp3MethodGenericType);
var exp3Arg1 = exp3.Arguments.Skip(1).ToArray();
var exp3ConvertExp = exp3Arg1.Length == 1 && exp3Arg1[0].Type.IsArray ?
Expression.Call(exp3ContainsMethod, exp3Arg1[0], exp3.Arguments[0]) :
Expression.Call(exp3ContainsMethod, Expression.NewArrayInit(exp3MethodGenericType, exp3Arg1), exp3.Arguments[0]);
return ExpressionLambdaToSql(exp3ConvertExp, tsc.CloneDisableDiyParse());
}
}
var ecc = new ExpressionCallContext
{
_commonExp = this,
Expand Down

0 comments on commit b0eb654

Please sign in to comment.