mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 20:38:16 +08:00
- 优化 lambda 使用 a == null ? 1 : 0 支持类似这样直接判断实体的情况;
This commit is contained in:
@ -496,6 +496,13 @@ namespace FreeSql.Internal
|
||||
return ExpressionLambdaToSql(Expression.Call(leftExp, MethodDateTimeSubtractTimeSpan, rightExp), tsc);
|
||||
}
|
||||
return $"({ExpressionLambdaToSql(leftExp, tsc)} {oper} {ExpressionLambdaToSql(rightExp, tsc)})";
|
||||
case "=":
|
||||
case "<>":
|
||||
var exptb = _common.GetTableByEntity(leftExp.Type);
|
||||
if (exptb != null) leftExp = Expression.MakeMemberAccess(leftExp, exptb.Properties[(exptb.Primarys.FirstOrDefault() ?? exptb.Columns.FirstOrDefault().Value).CsName]);
|
||||
exptb = _common.GetTableByEntity(leftExp.Type);
|
||||
if (exptb?.Primarys.Any() == true) rightExp = Expression.MakeMemberAccess(rightExp, exptb.Properties[(exptb.Primarys.FirstOrDefault() ?? exptb.Columns.FirstOrDefault().Value).CsName]);
|
||||
break;
|
||||
}
|
||||
|
||||
Type oldMapType = null;
|
||||
|
Reference in New Issue
Block a user