mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 修复 子查询 WhereIf 可能失败的 bug;
This commit is contained in:
parent
864eca6d72
commit
43e7bdce9c
@ -689,6 +689,18 @@ namespace FreeSql.Tests.Sqlite
|
|||||||
.Any()
|
.Any()
|
||||||
).Any()
|
).Any()
|
||||||
).ToList();
|
).ToList();
|
||||||
|
|
||||||
|
sql2222 = select.Where(a =>
|
||||||
|
select.Where(b => b.Id == a.Id &&
|
||||||
|
select
|
||||||
|
.Where(c => c.Id == b.Id)
|
||||||
|
.Where(d => d.Id == a.Id)
|
||||||
|
.Where(e => e.Id == b.Id)
|
||||||
|
.WhereIf(!sql2222.Any(), e => e.Id > 0)
|
||||||
|
.WhereIf(sql2222.Any(), e => e.Id >= 0)
|
||||||
|
.Any()
|
||||||
|
).Any()
|
||||||
|
).ToList();
|
||||||
}
|
}
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GroupBy()
|
public void GroupBy()
|
||||||
|
@ -1066,25 +1066,32 @@ namespace FreeSql.Internal
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var argExp = (arg3Exp as UnaryExpression)?.Operand;
|
var argExp = (arg3Exp as UnaryExpression)?.Operand;
|
||||||
if (argExp != null && argExp.NodeType == ExpressionType.Lambda)
|
if (argExp != null)
|
||||||
{
|
{
|
||||||
if (fsqltable1SetAlias == false)
|
if (argExp.NodeType == ExpressionType.Lambda)
|
||||||
{
|
{
|
||||||
fsqltable1SetAlias = true;
|
if (fsqltable1SetAlias == false)
|
||||||
var argExpLambda = argExp as LambdaExpression;
|
{
|
||||||
var fsqlTypeGenericArgs = fsqlType.GetGenericArguments();
|
fsqltable1SetAlias = true;
|
||||||
|
var argExpLambda = argExp as LambdaExpression;
|
||||||
|
var fsqlTypeGenericArgs = fsqlType.GetGenericArguments();
|
||||||
|
|
||||||
if (argExpLambda.Parameters.Count == 1 && argExpLambda.Parameters[0].Type.FullName.StartsWith("FreeSql.Internal.Model.HzyTuple`"))
|
if (argExpLambda.Parameters.Count == 1 && argExpLambda.Parameters[0].Type.FullName.StartsWith("FreeSql.Internal.Model.HzyTuple`"))
|
||||||
{
|
{
|
||||||
for (var gai = 0; gai < fsqlTypeGenericArgs.Length; gai++)
|
for (var gai = 0; gai < fsqlTypeGenericArgs.Length; gai++)
|
||||||
fsqltables[gai].Alias = "ht" + (gai + 1);
|
fsqltables[gai].Alias = "ht" + (gai + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (var gai = 0; gai < fsqlTypeGenericArgs.Length && gai < argExpLambda.Parameters.Count; gai++)
|
for (var gai = 0; gai < fsqlTypeGenericArgs.Length && gai < argExpLambda.Parameters.Count; gai++)
|
||||||
fsqltables[gai].Alias = argExpLambda.Parameters[gai].Name;
|
fsqltables[gai].Alias = argExpLambda.Parameters[gai].Name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
argExp = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
args[a] = argExp ?? Expression.Lambda(arg3Exp).Compile().DynamicInvoke();
|
args[a] = argExp ?? Expression.Lambda(arg3Exp).Compile().DynamicInvoke();
|
||||||
//if (args[a] == null) ExpressionLambdaToSql(call3Exp.Arguments[a], fsqltables, null, null, SelectTableInfoType.From, true);
|
//if (args[a] == null) ExpressionLambdaToSql(call3Exp.Arguments[a], fsqltables, null, null, SelectTableInfoType.From, true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user